This question arose while reading the new chapter in the excellent Learn You a Haskell about applicative functors.
The Applicative typeclass has, as part of the definition for the Maybe instance:
pure = Just
If I just go to GHCi and import Control.Applicative, and do:
pure (3+)
I don't get Just anything (makes sense). But if I use it in part of the expression:
pure (3+) <*> Just 4
I get Just 7. I guess it also isn't surprising, but I'm missing something integral about how typeclasses work, I think, that there is no ambiguity with the call to pure
here.
If my confusion makes sense, can anyone explain what's going on in detail?