How to fix DatatypeContexts?

Edward Kmett ekmett at gmail.com
Thu Jul 18 19:48:44 CEST 2013


This is exactly what GADTs are for.

-Edward

On Thu, Jul 18, 2013 at 6:54 AM, harry <voldermort at hotmail.com> wrote:

> data Eq a => Pair a = Pair {x::a, y::a}
>
> equal :: Pair a -> Bool
> equal pair = (x pair) == (y pair)
>
> This code will fail to compile, even with the deprecated DatatypeContexts
> extension, because equal must be given the Eq a => constraint, even though
> this has already been declared on the Pair type.
>
> Some of my code is littered with such redundant type constraints (although
> some of them could be replaced with a redundant pattern match). A proposal
> to enhance DatatypeContexts (#8026) in this way was rejected as unsound, as
> some nefarious uses of undefined would break the type system.
>
> Is there any way that the type system could be enhanced to avoid this
> redundancy?
>
>
>
> --
> View this message in context:
> http://haskell.1045720.n5.nabble.com/How-to-fix-DatatypeContexts-tp5733103.html
> Sent from the Haskell - Glasgow-haskell-users mailing list archive at
> Nabble.com.
>
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20130718/c86597e1/attachment.htm>


More information about the Glasgow-haskell-users mailing list