[racket-dev] Typed Racket interaction

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Mon Aug 2 10:43:23 EDT 2010

On Mon, Aug 2, 2010 at 9:37 AM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
> Here is a sequence of steps to do something that seems extremely
> simple.  I want to create a binary tree of T.
>
> First, I have no idea what this documentation means:
>
> (struct:n (t ...))
> is the type of structures named n with field types t.
>
> All of "struct", "n" and "t" are italicized, suggesting they're all
> meta-variables.  But only "n" and "t" are explained in the document.
> Perhaps "struct:" is meant literally?

This documentation is written confusingly, I'll fix that.

> The next few things I do fail miserably, until I get this far:
>
> (define-struct: (T) Node ([v : T] [l : (BinTreeof t)] [r : (BinTreeof t)]))
> (define-type (BinTreeof t)
>  (U 'empty
>     [Node t]))
>
> Now we get a classic impenetrable error message:
>
>  Type Checker: Structure type constructor Node applied to non-regular
>  arguments (Error) in: (Node t)
>
> Whatever that means.  I rename the two "t"'s in Node to "T"'s:
>
> (define-struct: (T) Node ([v : T] [l : (BinTreeof t)] [r : (BinTreeof t)]))
> (define-type (BinTreeof t)
>  (U 'empty
>     [Node t]))

This is the same code as above.  Did you mean something different?
-- 
sam th
samth at ccs.neu.edu


Posted on the dev mailing list.