[plt-scheme] typed scheme vs. PLAI types

From: Noel Welsh (noelwelsh at gmail.com)
Date: Mon Feb 15 06:49:22 EST 2010

Two errors:

Prop is not defined in the code you gave.

define-datatype creates a "tagged union", meaning each different type
of element is distinguished by a tag. In this case:

> (define-datatype RelExpr
>  (Rel ((rel : Relation)))
>  (Union ((rel1 : RelExpr) (rel2 : RelExpr)))
>  (Project ((rel : RelExpr) (attrs : Heading)))
>  (Restrict ((rel : RelExpr) (prop : Prop)))
>  (Join ((rel1 : RelExpr) (rel2 : RelExpr))))

the tags are Rel, Union, Project, Restrict, and Join. When you do this:

> (ann (make-Union suppliers_1-3 suppliers_4-5) RelExpr)

you don't add the tags to turn Relation into RelExpr. This work:

(eval-relexpr (make-Union (make-Rel suppliers_1-3) (make-Rel suppliers_4-5)))

Note the use of make-Rel.


Posted on the users mailing list.