[Haskell-cafe] More experiments with ATs

Andrew Coppin andrewcoppin at btinternet.com
Sun Jul 4 05:31:34 EDT 2010

Sjoerd Visscher wrote:
> On Jul 3, 2010, at 4:39 PM, Andrew Coppin wrote:
>> class Container c => Functor c where
>>   fmap :: (Functor cx, Functor cy, Element cx ~ x, Element cy ~ y) => (x -> y) -> (cx -> cy)
>> However, this fails horribly: The type signature fails to mention c.
> You have to mention c, this means an extra argument to fmap. But if you do that you also get the opportunity to restrict what x and y can be. 

Well, you can say

  class Container cy => Functor cy where
    fmap :: (Functor cx, Element cx ~ x, Element cy ~ y) => (x -> y) -> 
(cx -> cy)

But that's still wrong.

> As you'll have to pass around this extra argument, it will usually be easier to just pass around the map function though.
>> type family F f a :: *
>> class RFunctor f where
>>   (%) :: f a b -> (a -> b) -> F f a -> F f b

I have literally no idea what a type family is. I understand ATs (I 
think!), but TFs make no sense to me.

(For this reason, most if not all of the rest of this post doesn't make 

More information about the Haskell-Cafe mailing list