How to fix DatatypeContexts?

harry voldermort at
Thu Jul 18 13:52:14 CEST 2013

All of the proposed solutions seem to rely on pattern matching in the
constructor, which isn't always feasible. Here's a slightly better example:

data Pair a = (Num a, Eq a) => Pair {x::a,y::a}

equal :: Pair a -> Bool
equal pair = (foo pair) == (bar pair)

foo pair = (x pair) * (y pair)

bar pair = (y pair) + (x pair)

Now imagine that foo and bar are part of a library which I don't control, or
that for some other reason I can't just change foo and bar to take only the
components of Pair (e.g. it's a complex type with numerous components and

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