[racket-dev] Catching the undefined value

From: Neil Toronto (neil.toronto at gmail.com)
Date: Tue Apr 15 23:19:16 EDT 2014

On 04/15/2014 07:29 PM, Asumu Takikawa wrote:
> On 2014-04-15 18:13:31 -0400, claire alvis wrote:
>> The push below includes changes to letrec expressions, internal
>> definitions, units, classes, and certain ill-formed shared expressions so
>> that they no longer leak the `undefined' value.
>
> This is great! (especially happy that TR, even with classes, doesn't
> have to worry about #<undefined> anymore)

Does TR not having to worry about #<undefined> mean that the following 
program will typecheck?

   #lang typed/racket

   (define-type (Lazy-Listof A) (Promise (Pair A (Lazy-Listof A))))

   (let ()
     (define: lazy-zeros : (Lazy-Listof Zero)
       (delay (cons 0 lazy-zeros)))
     lazy-zeros)

Currently, `lazy-zeros' has the type (U Undefined (Lazy-Listof A)) 
within its definition, but only because it's in an internal definition 
context. This has come up in a few different guises while I've 
programmed in TR.

BTW, I was happy to see that the type `Lazy-Listof' could be defined 
like that when coming up with the example.

Neil ⊥


Posted on the dev mailing list.