[racket-dev] how to define a custom "null" in typed racket

From: Eric Dobson (eric.n.dobson at gmail.com)
Date: Thu Apr 11 18:47:33 EDT 2013

You shouldn't be able to send the TR into an inifinite loop.
Typechecking is supposed to terminate. Please try to reduce it to the
minimum testcase and file a bug.

On Thu, Apr 11, 2013 at 3:32 PM, Danny Yoo <dyoo at hashcollision.org> wrote:
> Perhaps something like this?
>
>
> ;;;;;;;;;;;;;
> #lang typed/racket/base
>
> (provide mynull mycar mycdr)
>
> (struct: MyNull ())
> (define mynull (MyNull))
>
> (define-type MyListof (All (A) (Rec X (U MyNull (Pair A X)))))
>
> (: mycar : (All (A) ((MyListof A) -> A)))
> (define (mycar lst)
>   (if (MyNull? lst)
>       (error 'mycar "given list is empty")
>       (car lst)))
>
> (: mycdr : (All (A) ((MyListof A) -> (MyListof A))))
> (define (mycdr lst)
>   (if (MyNull? lst)
>       (error 'mycdr "given list is empty")
>       (cdr lst)))
> ;;;;;;;;;;;;;
>
> where mynull is the singleton instance of the opaque structure type MyNull.
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev

Posted on the dev mailing list.