How to fix DatatypeContexts?

harry voldermort at
Thu Jul 18 14:35:36 CEST 2013

Sjoerd Visscher-2 wrote
> equal pair at Pair{} = foo pair == bar pair

Interesting solution, I didn't know you could do that. (Do all those who
suggested GADTs - you can add a type context to the constructor of a regular
data type as well, they don't bring you anything here.)

I've also been experiencing this a lot in class instances, such as:

class Foo f where
    foo :: a -> f a

data Bar f a = Foo f => Bar {bar :: f a}

instance Foo (Bar f) where
    foo a = Bar (foo a)

Is there any way to avoid repeating the Foo f constraint in the Bar f

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