Union Types for Haskell!?

Ashley Yakeley [email protected]
Fri, 24 Nov 2000 03:27:42 -0800


At 2000-11-24 03:14, Fergus Henderson wrote:

>> Is there any reason for this restriction
>> in the Haskell type system? Does this lead to losing the principal type
>> property?
>
>If you allow (2) above, there may be serious problems for
>principal types.  For example, consider
>
>	f x = case x of
>		Nothing -> False
>		Just _ -> True
>
>What's the most general type for `f'?
>The type `f :: Maybe a -> Bool' is less general than
>e.g. `f :: Union { Maybe a, ... } -> Bool',
>but you certainly don't want to infer the latter type.

There are two different kinds of 'general' here. Informally, you want the 
type most general in the type-substitution sense, but probably most 
specific in the subtype sense.

-- 
Ashley Yakeley, Seattle WA