Frederik Eaton writes: > > You need to swap the arguments to TCons... > > > > data TCons l a = TCons !l a > > > > Then: > > > > instance Functor (TCons (TCons HNil a)) where > > fmap f (TCons (TCons HNil x) y) = TCons (TCons HNil (f x)) y) > > How does one solve this problem in general, i.e. when the arguments to > a type are in the wrong order for an instance that one wants to > declare?
In general? You either make a newtype or change the definition of the original type. > Someone on the haskell IRC channel mentioned that if you could derive > instances for partially applied type synonyms then one could just > make a dummy synonym with the arguments in the right order, but that > doesn't appear to be premitted. The other question is why isn't it > permitted. As I understand it, the reason you can't do instances for partially applied type synonyms is because it makes instance selection ambiguous. For example: instance Functor ((,) a) where fmap f (x,y) = (x, f y) type RevPair a b = (b,a) instance Functor (RevPair a) where fmap f (x,y) = (f x, y) If I write 'fmap f (x,y)', do I get '(f x, y)' or '(x, f y)'? -- David Menendez <[EMAIL PROTECTED]> <http://www.eyrie.org/~zednenem/> _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe