
18 Jul
2013
18 Jul
'13
8:35 a.m.
Sjoerd Visscher-2 wrote
equal pair@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 instance? -- View this message in context: http://haskell.1045720.n5.nabble.com/How-to-fix-DatatypeContexts-tp5733103p5... Sent from the Haskell - Glasgow-haskell-users mailing list archive at Nabble.com.