On 9/16/07, Mads Lindstrøm <mads_lindstroem@yahoo.dk> wrote:
Hi all
If I have this type:
data Foo a b = ...
and this class
class Bar (x :: * -> *) where ...
I can imagine two ways to make Foo an instance of Bar. Either I must "apply" the 'a' or the 'b' in (Foo a b). Otherwise it will not have the right kind. To "apply" the 'a' I can do:
instance Bar (Foo a) where ...
But what if I want to "apply" the 'b' ? How do I do that ?
One easy way would be to create a newtype with the type parameters swapped: newtype Oof b a = Oof (Foo a b) instance Bar (Oof b) where ... Of course, if you want to partially apply the second parameter of a function, you use 'flip'. I thought for a while about whether there's some sort of typeclass hackery which is directly parallel to the use of 'flip', but couldn't come up with anything. Anyone? -Brent