Module Preface_specs.Bind

A Bind allow to sequences operations that are dependent from one to another, in contrast to Applicative, which executes a series of independent actions. It is a Monad without return operation.

Laws

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

  1. (m >>= f) >>= g = m >>= (fun x +> f x >>= g)
  2. join % join = join % (map join)
  3. map id = id
  4. map (g % f) = map g % map f
  5. map f % join = join % map (map f)
  6. map f % pure = pure % f
  7. (f >=> g) >=> h = f >=> (g >=> h)

Minimal definition

module type WITH_BIND = sig ... end

Minimal definition using bind.

module type WITH_MAP_AND_JOIN = sig ... end

Minimal definition using map and join.

module type WITH_KLEISLI_COMPOSITION = sig ... end

Minimal definition using compose_left_to_right.

module type WITH_MAP_AND_BIND = sig ... end

Minimal definition using map and bind.

module type WITH_MAP_AND_KLEISLI_COMPOSITION = sig ... end

Minimal definition using map and compose_left_to_right.

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 a Bind.

Additional references