This is now the fourth time I've seen people ask about this.<div><br></div><div>Why can't Typed Racket be a little different than Racket and have another match form that does this or a notion of disjoint unions?</div>
<div><br></div><div>You've said many times that TR is for converting Racket programs, but clearly some of us want to write quasi-ML in TR, but we can't without hacks like this.</div><div><br></div><div>Jay<br><br>
<div class="gmail_quote">On Fri, Dec 9, 2011 at 1:29 PM, Sam Tobin-Hochstadt <span dir="ltr"><<a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I think what you're asking for is static errors for coverage failures<br>
in `match' when used in Typed Racket.<br>
<br>
There are two reasons this isn't something I'm planning on doing in general:<br>
1. It would be a significant change from the semantics of `match' in<br>
Racket, which as you note raises a runtime error.<br>
2. It's unlikely to be precise enough in enough cases to be useful.<br>
`match' is just too flexible, and TR insufficiently smart, for this to<br>
be the right default.<br>
<br>
However, for this purpose, Typed Racket provides the `typecheck-fail'<br>
form [1], for raising explicit type errors. Rewrite your match<br>
expression to:<br>
<div class="im"><br>
(match f<br>
[(list s) #true]<br>
</div> [_ (typecheck-fail #'here #:covered-id f)])<br>
<br>
and you get the error message:<br>
Type Checker: Incomplete case coverage; missing coverage of Foo<br>
<br>
[1] <a href="http://pre.racket-lang.org/docs/html/ts-reference/Utilities.html?q=type-e#%28form._%28%28lib._typed-racket/base-env/prims..rkt%29._typecheck-fail%29%29" target="_blank">http://pre.racket-lang.org/docs/html/ts-reference/Utilities.html?q=type-e#%28form._%28%28lib._typed-racket/base-env/prims..rkt%29._typecheck-fail%29%29</a><br>
<div><div></div><div class="h5"><br>
On Fri, Dec 9, 2011 at 3:20 PM, <<a href="mailto:clements@brinckerhoff.org">clements@brinckerhoff.org</a>> wrote:<br>
> *** Description:<br>
> Code using match to take apart opaque types<br>
> signal runtime match failure rather than<br>
> a type-checking failure.<br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
sam th<br>
<a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a><br>
</font></blockquote></div><br><br clear="all"><div><br></div>-- <br>Jay McCarthy <<a href="mailto:jay@cs.byu.edu" target="_blank">jay@cs.byu.edu</a>><br>Assistant Professor / Brigham Young University<br><a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
<br>"The glory of God is Intelligence" - D&C 93<br>
</div>