[racket] From types to contracts

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Nov 18 09:02:51 EST 2014

FWIW, parametric types converted to contracts may change the behavior of the program. It violates a basic axiom of the gradual typing program but it is a pragmatic "thing". 




On Nov 17, 2014, at 11:26 PM, Benjamin Greenman <blg59 at cornell.edu> wrote:

> I'd like to convert the following typed program into an untyped one that uses a contract instead of a type signature to protect the member function.
> 
> #lang typed/racket
> (struct: (A) Node ([val : A]
>                    [left-tree  : (MyTree A)]
>                    [right-tree : (MyTree A)]))
> (define-type (MyTree A) (U 'Nil (Node A)))
> 
> (: member (All (A) (-> A (MyTree A) Boolean)))
> (define (member x xs)
>   #t)
> 
> More specifically, can someone help me fill in the blank marked "TODO" below:
> 
> #lang racket
> (struct Node (val left-tree right-tree))
> 
> (define/contract (member x xs)
>   (parametric->/c [A] TODO)
>   #t)
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.