Typed Racket
Go to file
Eric Dobson 3b80ae71f9 correct keyword function conversion
Keyword functions are a little tricky. This PR addresses issues
checking the body of kw functions.

Basically, a function with keyword arguments such as inc:

(define (inc x #:n [n 1])
  (+ x n))

actually expands into a more complex function with 3 arguments that
looks something resembling the following:

(define (inc-expanded n* n-given? x)
   (let ([n (if n-given? n* 1)]) (+ x n)))

and calls to inc are converted to match this form:

(inc 42) => (inc-expanded #f #f 42)

(inc 42 #:n 2) => (inc-expanded 2 #t 42)

Note that each optional keyword argument has a boolean flag argument
that signals whether or not the caller provided that keyword argument.

This PR takes advantage of the observation that the value for the n*
argument in inc is only reachable in code when n-given? is #t, and so,
assuming the kw-expansion protocol always only accesses n* if n-given?
is #t, we can actually safely check the body of the function against
the following simple but correct type:

(-> Number Boolean Number Number)

An alternative previous approach expanded the function type into every
possible combination of optional argument and optional argument flag,
but this was prohibitively expensive.
2017-01-07 12:36:01 -05:00
source-syntax Remove extra directories. 2014-12-02 00:53:36 -05:00
typed-racket Add syntax for poly structs in require/typed 2016-07-21 12:00:08 -04:00
typed-racket-compatibility Add syntax for poly structs in require/typed 2016-07-21 12:00:08 -04:00
typed-racket-doc Add #lang typed/racket/gui/no-check (#467) 2017-01-06 11:29:04 -05:00
typed-racket-lib correct keyword function conversion 2017-01-07 12:36:01 -05:00
typed-racket-more in-query returns a sequence of single value (#468) 2017-01-06 11:34:54 -05:00
typed-racket-test correct keyword function conversion 2017-01-07 12:36:01 -05:00
.gitignore Add standard .gitignore file. 2014-12-06 17:46:25 -05:00
.travis.yml Revise Travis tests for 43a8cce3f. 2015-12-29 17:58:00 -05:00
issue_template.md Create issue_template.md 2016-02-17 14:51:06 -05:00
README.md Fix Travis image URL in the README 2015-02-25 15:17:13 -05:00

Typed Racket

Build Status

Typed Racket is Racket's gradually-typed sister language which lets you add statically-checked type annotations to your programs. For more information, see the Typed Racket Guide.

Installation

Typed Racket is bundled in the default Racket distribution, which you can download from Racket's download page.

You can also manually install it from the main package catalog with the following command:

raco pkg install typed-racket

Documentation

The documentation is also bundled in your local copy of Typed Racket.


Copyright (c) 2010-2015 PLT Design Inc.

This package is distributed under the GNU Lesser General Public License (LGPL). This means that you can link this package into proprietary applications, provided you follow the rules stated in the LGPL. You can also modify this package; if you distribute a modified version, you must distribute it under the terms of the LGPL, which in particular means that you must release the source code for the modified software. See http://www.gnu.org/copyleft/lesser.html for more information.