
It's true that GADTs does just that. But only if you use them. And they are not part of Haskell. :) -- Lennart Jacques Carette wrote:
I was under the impression that, in ghc 6.4 at least, GADTs did just that: use information gained by matching on the type constructor to refine types. I sort-of expected that the extension to pattern matching would follow.
Or is that a nice paper waiting to be written?
Jacques
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.
-- Lennart