haskell-cafe@haskell.org
[Top] [All Lists]

Re: [Haskell-cafe] classes with types which are wrapped in

Subject: Re: [Haskell-cafe] classes with types which are wrapped in
From: Reid Barton
Date: Fri, 22 Jan 2010 11:25:41 -0500
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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>