On Tue, Sep 7, 2010 at 8:04 AM, Jay McCarthy <jay.mccar...@gmail.com> wrote:
>
>> Why does everyone always want to use union for this?  Everything you
>> wrote there is correct, except that `U' should be `case-lambda'.
>
> There is something to be said for making the things that everyone
> writes first be the thing they should write. It is natural to me to
> think of a function with multiple arrow types as a union of some arrow
> types. Would it be so hard for Typed Racket to see a union of all
> arrows and just consider that the same as case-lambda? Is that wrong?

Yes, that's fundamentally wrong.  But I think your description makes
me see why people get this wrong.  If you think of a case-lambda as
"combining" in some sense a bunch of different functions, so that the
actual function is a set of smaller functions, then the union
interpretation makes sense.

The reason this is wrong is that isn't what union types mean at all -
they're a union in the set of *possible* values.  For example, the
inhabitants of the type (U Number String) aren't values that are some
combination of numbers and strings, the values are either numbers, or
strings.  Similarly, the inhabitants of the type Eli wrote might be a
function with *just one* of those behaviors (that type is a perfectly
good TR type), which wouldn't serve the purpose at all.

> If it is fundamentally wrong, some better form of explanation in the
> docs seem warranted.

I'll see about adding a note those.
-- 
sam th
sa...@ccs.neu.edu
_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

Reply via email to