[Haskell-cafe] Bug in GADT Implementation?

Roberto Zunino zunino at di.unipi.it
Sat May 26 16:00:02 EDT 2007


Dominic Steinitz wrote:
> I would expect
> 
> foo r@(Range BITSTRING _ _) x = []
> 
> to give an error but it doesn't. Writing
> 
> t = Range BITSTRING
> 
> gives one so why not the pattern match?

AFAICS, this is because when you construct a value, as in t, you have to
provide the required context (Ord in this case) or face an error. OTOH,
when you destruct a value, you simply get the context back and you are
not required to provide anything, so no type error is generated.

This works in HEAD:

data A
data Foo where F :: Num A => Foo

bar :: Foo -> A
bar F = 42

Regards,
Zun.


More information about the Haskell-Cafe mailing list