Typed Racket
Go to file
Andrew Kent 8e7f39025a remove interning for most Reps in TR
Prior to this change (which was Typed Racket PR 469) all internal TR
objects (Reps) were interned and kept around for the entire duration
of type checking.  Because of this, frequent operations that rebuilt
types were particularly costly (e.g. various forms of
substitution). To recoup some of this cost, caching was being used in
a lot of places. This PR sought to remove interning as the default
behavior for Reps and allow for more flexibility in how we approach
time/space performance needs going forward.

The following changes were included in this overhaul:

Interning: All Reps are no longer interned. Right now we only intern
unions and some propositions.

Rep generic operations: we now use racket/generic so we're not
reinventing this wheel.

Singletons: Reps (e.g. TrueProp, Univ, etc) can be declared singleton,
which creates a single instance of the rep that all visible operations
(even within the declaring module) are defined in terms of
(e.g. predicates are defined as (λ (x) (eq? x singleton-instance)),
etc).

Custom constructors: Custom constructors can be specified for Reps,
which allows for simple normalization, interning, or other invariants
to be enfored whenever a Rep is created.

Union: Unions used to try to ensure no obviously overlaping types
would inhabit the same Union (e.g. (U String (Pairof Any Any) (Pairof
Int Int)) would be simplified to (U String (Pairof Any Any))). This,
however, required frequent calls to subtyping every time a Union was
modified and working with Unions thus had a high cost (another thing
that caching was used to reduce). Instead of this, Unions now enforce
a much simpler set of invariants on their members: (1) No duplicates
(by virtue of using a hash-based set), (2) Any and Nothing do not
appear in unions, and (3) Nested unions are flattened. Also, using a
hashset as the internal data structure meant that we could easily
intern unions w.r.t. equal? equality. NOTE: we do reduce unions to not
contain obviously overlapping terms when printing to users and when
generating contracts (so obviously and avoidable inneficient contracts
are not generated – See union.rkt for 'normalize-type').

Subtyping changes: Subtyping has been designed to reduce dispatch time
w/ a switch since we no longer cache _all_ subtyping calls (we only
cache subtyping results for unions since they have some costly
subtyping).

prop-ops changes: AndProps now are careful to sort OrProps by length
before building the resulting proposition. This is done because
OrProp implication only checks if one Or is a subset of another Or.
By ordering Or props by size, we only ever check if an OrProp implies
another if its size is <= the other OrProp. This also makes the
smart constructor '-and' more robust, since the order the props
appear does not affect if some Ors are kept or not.

Testing: More subtype tests have been added (we are still probably
relying too much on typecheck-tests.rkt and not the more granular unit
tests in general).  Also, typecheck-tests.rkt has been changed to
check for type-equivalence (i.e. subtyping in both directions)
instead of equal? equivalence.
2016-12-16 15:18:50 -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 typed racket doc typo 2016-11-03 15:55:22 -04:00
typed-racket-lib remove interning for most Reps in TR 2016-12-16 15:18:50 -05:00
typed-racket-more remove interning for most Reps in TR 2016-12-16 15:18:50 -05:00
typed-racket-test remove interning for most Reps in TR 2016-12-16 15:18:50 -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.