From 0e9de12d91d70eb607cc83dc05a98b0285a79ee6 Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Wed, 28 May 2014 22:57:02 -0700 Subject: [PATCH] Initial internal Typed Racket documentation. Still needs to be scribbled, and have lots more added. original commit: 29bb045942af08889ab6088ffb0ec0ae8d6d4ac3 --- .../typed-racket/scribblings/internals.txt | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/internals.txt diff --git a/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/internals.txt b/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/internals.txt new file mode 100644 index 00000000..380ad9e7 --- /dev/null +++ b/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/internals.txt @@ -0,0 +1,25 @@ +Data Structures used in Typechecking. +The main data structure used in typechecking is a tc-results/c. +This currently has two variants +(struct/c tc-results ((listof (struct/c tc-result (Type/c FilterSet? Object?))) + (or/c #f (cons/c Type/c symbol?)))) +(struct/c tc-any-results (or/c Filter/c NoFilter?)) + +The first represents a fixed number of values with optional dotted return values. +The second represents an unknown number of values. + +A value has three main parts: a Type, a FilterSet, and an Object. For dotted values we do no store a +FilterSet or an Object because they would almost never be useful. They are thus implicitly -top-filter +and -empty-obj. In the tc-any-results case since we don't know the number of values, we do not store +the Type or the Object, but we do store a filter. This is useful in cases like +(let ((x (read))) + (unless (number? x) (error 'bad-input)) + (do-stuff x)) + + +Inference and Sequences +Typed racket has many types which can have a subpart which is a sequence of different types, for +example heterogenous lists or arguments to a function. We assume such sequences take one of three forms. +A fixed prefix followed by either a dotted tail, a uniform tail, or no more types. The subtyping +relationship has 9 different cases corresponding to the product of the cases. This is implemented once +for a generic sequence, and each other type converts itself to a sequence to implement inference.