Hello, for anyone interested, type of fmap (const '2') Just
is:
ghci> :t fmap (const '2') Just
fmap (const '2') Just :: a -> Char
And for every input answear will be '2'
. Now, I want to know how to derive it. At the beginning I though that Char
is just functor, and fmap
would just applied (const '2') Just
like this:
fmap (const '2') Just $ '3' =
fmap ( (const '2') Just ) 3 =
const '2' (Just 3) =
'2'
or something like this:
fmap (const '2') Just $ '3' =
fmap ( (const '2') Just $ 3) =
-- fmap would do nothing?
(const '2') Just 3 =
'2'
But I think everything I wrote is wrong and just blindly guessing.
My question is, is there better and mechanical method to always correctly derive type? If that have something with lambda calcules or other subject, Iβm willing to learn.