Preface_specs.ApplicativeAn Applicative is a functor with lifting and sequencing capabilities. Applicative is more general (and by extension weaker) than a Monad. An Applicative is also a Functor.
To have a predictable behaviour, the instance of Applicative must obey some laws.
apply = lift2 idlift2 f x y = f <$> x <*> ypure id <*> v = vpure (%) <*> u <*> v <*> w = u <*> (v <*> w)pure f <*> pure x = pure (f x)u <*> pure y = pure ((|>) y) <*> uu *> v = (id <$ u) <*> vu <* v = lift2 const u vfmap f x = pure f <*> xlift2 p (lift2 q u v) = lift2 f u % lift2 g vmodule type WITH_PURE = sig ... endMinimal interface using map and product.
module type WITH_PURE_MAP_AND_PRODUCT = sig ... endMinimal interface using map and product.
module type WITH_PURE_AND_APPLY = sig ... endMinimal interface using apply.
module type WITH_PURE_AND_LIFT2 = sig ... endMinimal interface using lift2.
module type CORE = sig ... endBasis operations.
module type OPERATION = sig ... endAdditional operations.
module type SYNTAX = sig ... endSyntax extensions.
module type INFIX = sig ... endInfix operators.
module type API = sig ... endThe complete interface of an Applicative.