[Haskell-cafe] type inference and named fields

Henning Thielemann lemming at henning-thielemann.de
Thu Jun 23 14:26:08 EDT 2005


On Thu, 23 Jun 2005, Lennart Augustsson wrote:

> A somewhat similar problem exists even without fields:
>
> foo :: Either a b -> Either () b
> foo (Left _) = Left ()
> foo x@(Right _) = x
>
> Since Haskell type checking doesn't use the information gained
> by pattern matching to refine types we just have to accept that
> some perfectly safe programs don't type check.

This sounds like the discussion about whether it is sensible to
distinguish between empty lists of different types. Definitely yes! As
well as ([] :: [a]) is not the same as ([] :: [()]) it must be (Right x ::
Either a b) different from (Right x :: Either () b).



More information about the Haskell-Cafe mailing list