I am playing with Control.Applicative and I am realizing I don't understand everything with the Haskell type system.
Here is my experiment in Ghci:
λ :t (<*>)
(<*>) :: Applicative f => f (a -> b) -> f a -> f b
λ :t (<*>) (pure 2)
(<*>) (pure 2) :: (Num (a -> b), Applicative f) => f a -> f b
The type of the first argument of <*> is f (a -> b).
- Why is this expression correct?
- How can it be unified with
(pure 2)since the constant2is not of typea -> b? - What does
Num (a -> b)mean? How can a function having aa -> btype be an instance ofNum?