
On Thursday 25 April 2013, 08:03:25, gs wrote:
Daniel Fischer
writes: ...
You've mentioned GADT a few times, but I can't find a case where it's different to regular datatypes.
data Foo a = Eq a => Foo a
seems to have the same effect as
data Foo a where Foo a :: Eq a => a -> Foo a
Both remember the Eq constraint if I pattern match on the constructor, and both ignore it otherwise.
Oy, sorry, I didn't look properly and moved the constraint before the datatype name (data Eq a => Foo a = Foo a) in my brain, which would be a datatype context. The data Foo a = Eq a => Foo a syntax (requires ExistentialQuantification or GADTs) is indeed equivalent to the GADT syntax or existential quantification. Oh well, at least the part explaining how that requires pattern matching to make the context available remains useful.