Hi,

I am trying to understand some differences of parameterizing or not some
arguments of type families.
I have some code such as

*type family G a :: * -> *

instance Functor (G Int) where
   fmap f (Left ()) = Left ()
   fmap f (Right x) = Right (f x)

ggg :: Functor (G a) => G a x -> G a x
ggg = fmap id*

and it works fine.
However, I need to parameterize one extra argument (due to type equality):

*type family F a x :: *

class FunctorF d where
    fmapF :: (x -> y) -> F d x -> F d y

fff :: (FunctorF a) => F a b -> F a b
fff = fmapF id*

This second scenario fails to compile because the compiler cannot unify
types a and b with types d and x from the fmapF declaration.
Is there any other option than passing dummy variables to fmapF?
*
class FunctorF d where
    fmapF :: d -> x -> (x -> y) -> F d x -> F d y

fff :: (FunctorF a) => a -> b -> F a b -> F a b
fff a b = fmapF a b id*

Thanks,
hugo
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to