data Foo a where
Foo :: Eq a => a -> Foo a
> data Foo a where
> Foo :: Eq a => a -> Foo a
>
> is equivalent to
>
> data Foo a = Eq a => Foo a
>
> but is different from
>
> data Eq a => Foo a = Foo a
... and nothing in GADTs does what one would naively expect the last
declaration to do.
If I understand correctly, the problem with datatype contexts is that if we
have e.g.
data Eq a => Foo a = Foo a
the constraint Eq a is thrown away after a Foo is constructed, and any
method using Foos must repeat Eq a in its type signature.
Why were these contexts removed from the language, instead of "fixing" them?
Dan Doel <dan.doel <at> gmail.com> writes:... which means that implementers should be free to "fix" data type contexts
> However, another thing to consider is that getting rid of data type
contexts was accepted into the language standard.
however they like, as they are now complier extensions which won't conflict
with standard Haskell.
> ... which means that implementers should be free to "fix" data type contexts"Remembering" data type contexts shouldn't break existing code, unless it's
> however they like, as they are now complier extensions which won't conflict
> with standard Haskell.
>
> Except that people do build older programs with newer Haskell compilers,
and it's bad to "repurpose" a syntax like that because it leads to strange
errors.
semantically broken already. (I'm sure that anyone could come up with a
theoretical example of code which would break
- but would it break any
real-world code?)
> I do not support that criterion. We use theory to ENSURE that no
real-world code will break.
By theoretical example, I meant something which you would never expect to
find in use. Perhaps it was a poor choice of wording in an academically
orientated forum :-)
Alexander Solla <alex.solla <at> gmail.com> writes:By theoretical example, I meant something which you would never expect to
> I do not support that criterion. We use theory to ENSURE that no
real-world code will break.
find in use. Perhaps it was a poor choice of wording in an academically
orientated forum :-)