[Haskell-beginners] Functor instance
sasa bogicevic
brutallesale at gmail.com
Mon Jan 9 15:41:39 UTC 2017
Hi all,
Can someone explain to me why exactly when defining the Functor instance for type that has polimorphic parameter constraint I am not allowed to put that parameter in definition. So basically:
data Four a b c d = Four a b c d
instance Functor (Four a b c) where <-- why can't I specify also param d here ??
fmap f (Four a b c d) = Four a b c (f d)
I asked the same question on IRC and got the answer that it is because of Functor has kind * -> *. I thought I understand it but it is not clear to me completely. I understand type kinds on examples I looked at before but
when looking at this Functor instance why exactly I don't specify all params for the type and while we are at it why don't I also specify f param for the Functor like this "instance Functor f (Four a b c d) where ...".
Thanks, Sasa
{
name: Bogicevic Sasa
phone: +381606006200
}
More information about the Beginners
mailing list