[racket-dev] type-case + typed racket yet?
In what sense did you screw up? Even in ML all you get is a warning that your cases aren't exhaustive -- and so you get a run-time exception. So what? Run-time exceptions are a part of the standard type soundness theorem. -- Matthias
On May 25, 2011, at 7:53 PM, Danny Yoo wrote:
> 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
> 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