[racket] [typed racket] type case

From: Vincent St-Amour (stamourv at ccs.neu.edu)
Date: Sun Oct 23 11:39:26 EDT 2011

At Sun, 23 Oct 2011 12:03:23 -0300,
Eric Tanter wrote:
> However, of course, this does not work if the return type is compatible with Void:
> (: f ((U String Integer) -> Any))
> (define (f x)
>   (cond
>     [(string? x) (string=? x "hi")]
>     [(exact-nonnegative-integer? x) (= x 7)]))
> typechecks.

Using `Any' as a return type is something I only do as a quick and
dirty solution. I assume that if you care enough to want case
exhaustiveness checking, you probably care enough to nail down your
return types precisely.

If you actually _need_ to use `Any' as a return type, this is
something that really should stick out and be documented.

> I guess you could include a type Invalid, which is NOT a subtype of Any.

That sounds like a bad idea.


Posted on the users mailing list.