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.