ConstraintKinds and default associated empty constraints
andres.loeh at googlemail.com
Mon Jan 9 08:28:21 CET 2012
> The definitions are accepted by GHC:
> class Functor f where
> type FC f a :: Constraint
> type FC f a = ()
> fmap :: (FC f a, FC f b) => (a -> b) -> f a -> f b
> instance Functor  where
> fmap = map
Yes. This is what I would have expected to work.
> But I don't like the 'a' being an index parameter, and then the
> following expression:
> fmap (+1) [1::Int]
> Gives the error:
> Could not deduce (FC  Int) arising from a use of `fmap'
> In the expression: fmap (+ 1) [1 :: Int]
> In an equation for `it': it = fmap (+ 1) [1 :: Int]
>> gives the error:
>> Number of parameters must match family declaration; expected 1
>> In the type synonym instance default declaration for `FC'
>> In the class declaration for `Functor'
I get the same error, but it looks like a bug to me: If I move the
type FC f a = ()
to the instance, then the example passes.
More information about the Glasgow-haskell-users