
On 22 December 2011 01:58,
Quoting Bas van Dijk
: I'm playing a bit with the new ConstraintKinds feature in GHC 7.4.1-rc1. I'm trying to give the Functor class an associated constraint so that we can make Set an instance of Functor. The following code works but I wonder if the trick with: class Empty a; instance Empty a, is the recommended way to do this:
Maybe something like this?
class Functor f where type C f a :: Constraint type C f a = ()
instance Functor Set where type C Set a = Ord a
~d
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Yes I already tried that, but the following gives a type error: instance Functor [] where fmap = map testList = fmap (+1) [1,2,3] Could not deduce (C [] b0) arising from a use of `fmap' In the expression: fmap (+ 1) [1, 2, 3]