package preface

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

An 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.

Laws

To have a predictable behaviour, the instance of Applicative must obey some laws.

  1. apply = lift2 id
  2. lift2 f x y = f <$> x <*> y
  3. pure id <*> v = v
  4. pure (%) <*> u <*> v <*> w = u <*> (v <*> w)
  5. pure f <*> pure x = pure (f x)
  6. u <*> pure y = pure ((|>) y) <*> u
  7. u *> v = (id <$ u) <*> v
  8. u <* v = lift2 const u v
  9. fmap f x = pure f <*> x
  10. lift2 p (lift2 q u v) = lift2 f u % lift2 g v

Minimal definition

module type WITH_MAP_AND_PRODUCT = sig ... end

Minimal interface using map and product.

module type WITH_APPLY = sig ... end

Minimal interface using apply.

module type WITH_LIFT2 = sig ... end

Minimal interface using lift2.

Structure anatomy

module type CORE = sig ... end

Basis operations.

module type OPERATION = sig ... end

Additional operations.

module type SYNTAX = sig ... end

Syntax extensions.

module type INFIX = sig ... end

Infix operators.

Complete API

module type API = sig ... end

The complete interface of an Applicative.

Additional references

OCaml

Innovation. Community. Security.