On Wed, May 25, 2011 at 3:53 PM, Sam Tobin-Hochstadt <sa...@ccs.neu.edu> wrote:
> On Wed, May 25, 2011 at 12:27 PM, John Clements
> <cleme...@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
                       SomeStruct2))
(define-struct: SomeStruct1 ())
(define-struct: SomeStruct2 ())

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

Typed Racket doesn't tell me statically that I've screwed up here.
_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

Reply via email to