How to fix DatatypeContexts?
harry
voldermort at hotmail.com
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
subcomponents).
--
View this message in context: http://haskell.1045720.n5.nabble.com/How-to-fix-DatatypeContexts-tp5733103p5733110.html
Sent from the Haskell - Glasgow-haskell-users mailing list archive at Nabble.com.
More information about the Glasgow-haskell-users
mailing list