
23 Jun
2005
23 Jun
'05
2:26 p.m.
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).