How to fix DatatypeContexts?

harry voldermort at
Thu Jul 18 12:54:06 CEST 2013

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

View this message in context:
Sent from the Haskell - Glasgow-haskell-users mailing list archive at

More information about the Glasgow-haskell-users mailing list