[racket-dev] type-case + typed racket yet?

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Wed May 25 19:53:35 EDT 2011

On Wed, May 25, 2011 at 3:53 PM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
> On Wed, May 25, 2011 at 12:27 PM, John Clements
> <clements at brinckerhoff.org> wrote:
>> Is there a "best-practice" model for type-case-like things in typed racket yet? Obvious choices:
>> - tagged-list style, it's all a big cond but I have to use first, second, etc to refer to fields
>> - struct-union style, feels better but I don't get to use match (IIUC).
> `match' and unions of structs should work fine together in Typed Racket.

But doesn't racket/match interfere with catching bugs with forgetting
a case?  When I do something like this:

#lang typed/racket/base
(require racket/match)

(define-type MyType (U SomeStruct1
(define-struct: SomeStruct1 ())
(define-struct: SomeStruct2 ())

(: stringify (MyType -> String))
(define (stringify x)
  (match x
    [(struct SomeStruct1 ())

Typed Racket doesn't tell me statically that I've screwed up here.

Posted on the dev mailing list.