Applicative

This week’s theme is applicative functors. The eighth lesson of Functortown is called Mapping a Maybe function. Applicative is one of our favorite typeclasses, and this is the first of several Applicative lessons.

Its primary method,

(<*>) :: Applicative f =>
    f (a -> b) -> f a -> f b

tends to cause confusion if we cannot readily imagine circumstances in which an f (a -> b) value may arise. So we starts off with a concise practical example that naturally brings the Maybe applicative to our attention.

To go along with the applicative series in functortown, we’ve also written the reference page on the ApplicativeDo extension. This is a fun augmentation of do syntax that was introduced into GHC in 2016. It lets Haskell really embrace Applicative composition, and you may want to enable it to make your code prettier or more efficient.