Applicative do
Contents
- The desugaring
- Preservation of Monad semantics
- Applicatives without Monads
validationasyncoptparse-applicative
- When Applicative is more efficient
haxlcontainers
- With only a Functor
Normally, do notation is syntactic sugar over monadic functions and desugars into monadic combinators such as (>>=). The ApplicativeDo language extension enables an alternate desugaring, allowing do syntax to be used in an Applicative context as well.
There are two reasons to enable the ApplicativeDo extension:
- When a type constructor has an
Applicativebut noMonad. - When composition using
(<*>)is more efficient than the corresponding composition using(>>=).
There is (in principle) no reason not to enable ApplicativeDo, but see the preservation of monad semantics section below for caveats.
ApplicativeDo was introduced into GHCRelease notes for GHC 8.0.1 in version 8.0.1 in 2016.

