[Haskell-cafe] FGL instance constraint
Kevin Quick
quick at sparq.org
Sat May 1 01:25:20 EDT 2010
I need help understanding how to express the following:
> data (Cls a) => B a = B [a]
> data GrB a b = GrB (B a)
> instance Graph GrB where ...
In the methods for the instance specification, I need to perform Cls a operations on a.
* As shown, the compiler complains that it cannot deduce (Cls a) from the context () on those methods.
* I can't redefine the Graph methods to introduce the (Cls a) constraint [reasonable]
* If I try to express the constraint as part of the Graph instance: "instance (Cls a) => Graph GrB where ..." then it says it's an ambiguous constraint because 'a' isn't mentioned.
* I've tried specifying a functional constraint: "instance (Cls a) => Graph GrB | GrB -> a where ..." but that's not valid for an instance declaration.
* I can't include a in the GrB instance: "instance (Cls a) => Graph (GrB a b) where ..." because that's a kind conflict.
Suggestions/solutions are appreciated.
Thanks!
--
-KQ
More information about the Haskell-Cafe
mailing list