[Haskell-cafe] classes with types which are wrapped in
Reid Barton
rwbarton at math.harvard.edu
Fri Jan 22 11:25:41 EST 2010
On Fri, Jan 22, 2010 at 05:08:15PM +0100, Andrew U. Frank wrote:
> i encounter often a problem when i have a class with some operations (say
> class X with push) applied to a type A b. I then wrap A in a type A_sup, with
> some more type parameters and i cannot write a instance of class A_sup because
> i have a kind mismatch. any suggestions? (reordering of the type parameters of
> A_sup is not a solution, because another class operates on this parameter)
>
> here a simplistic case (i know that A could be reduced to [], my real cases
> are more complicated).
>
> data A b = A b [b]
>
> data Asup x ab y = Asup x ab y
>
> class X a b where
> push :: b -> a b -> a b
This is a little strange. Are you sure you don't want either
class X a where
push :: b -> a b -> a b
or
class X a b where
push :: b -> a -> a
? The second one might help you with your subsequent problem
(although I didn't understand quite what you were trying to do there).
Regards,
Reid Barton
More information about the Haskell-Cafe
mailing list