
If you imagine a type as a box with some slots (each slot for each
type variable), Functor only allows you to map on the last slot. That
and the currying of functions lead to the intuition behind "Functor
has kind * -> *" (aka: you need the type for the last slot to fully
build the type that would be an instance of Functor)
On Mon, Jan 9, 2017 at 7:41 AM, sasa bogicevic
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 }
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-- Mihai Maruseac (MM) "If you can't solve a problem, then there's an easier problem you can solve: find it." -- George Polya