What's wrong instance Functor Int where
instance Functor Int where
fmap f a = f a
Expected kind ...
I can't make monad int , applicative int, functor int
What is so interesting about Maybe a, [a], Either e a, IO a? The type takes an additional parameter. That is, Maybe on its own isn't a type. You have to use another type e.g. Int to actually get a type: Maybe Int.
Let's have a look at Functor's definition:
class Functor f where
fmap :: (a -> b) -> f a -> f b
-- ^^^ ^^^
Whatever you use for f must be able to use a type. And Int Int or Int () is not a type, because Int is already at kind *. You cannot construct another type by applying Int on something else.
Maybe on the other hand is of kind * -> *. It takes a type (e.g. Double) and returns a type, Maybe Double:
-- using pseudo kind-signatures
Maybe :: * -> *
Double :: *
Maybe Double :: *
All that because our f takes an a in the signature of fmap.
So no. You cannot make any regular type (of kind *) an instance of Functor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With