I’m reading the LYAH chapter on applicative functors, and I don’t seem to understand the following example:
ghci> :t fmap (++) (Just "hey")
fmap (++) (Just "hey") :: Maybe ([Char] -> [Char])
But when I look at this:
ghci> :t (++)
(++) :: [a] -> [a] -> [a]
ghci> :t fmap
fmap :: Functor f => (a -> b) -> f a -> f b
I do understand how something like (*3) or (++”this”) fits into the (a -> b) type, but I just can’t see how [a] -> [a] -> [a] fits into (a -> b)?
Putting the stuff side-by-side as usual,
So,
No thinking is involved here. Unification of types is a mechanical process.
And to answer your specific question (paraphrased), ” how
[c] -> [c] -> [c]can be matched witha -> b“, here goes: