It is worth looking at the type that the compiler requests for pure (3+) :
Prelude Control.Applicative> :t pure (3+) pure (3+) :: (Num a, Applicative f) => f (a -> a)
The type of this term is overloaded, and the decision on the numerical class and applicative class is postponed until a later time. But you can force to create a specific type with annotation, for example:
*Showfun Control.Applicative> pure (3+) :: Maybe (Double -> Double) Just <function>
(This works because Showfun has an instance declaration that prints the value of the function as <function> .)
It is simply a matter of when the compiler has accumulated enough information to make a decision.
source share