package preface

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

A Comonad is the dual of the Monad.

Laws

  • extend extract = id
  • (extend %> extract) f = f
  • extend g %> extend f = extend (extend g %> f)
  • f =>= extract = f
  • extract =>= f = f
  • (f =>= g) =>= h = f =>= (g =>= h)
  • extract <% duplicate = id
  • fmap extract <% duplicate = id
  • duplicate %> duplicate = fmap duplicate <% duplicate
  • extend f = fmap f <% duplicate
  • duplicate = extend id
  • fmap f = extend (f <% extract)

Minimal definition

module type WITH_MAP_AND_DUPLICATE = sig ... end

Minimal definition using extract, map and duplicate.

module type WITH_EXTEND = sig ... end

Minimal definition using extract and extend.

module type WITH_COKLEISLI_COMPOSITION = sig ... end

Minimal definition using extract 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 Comonad.

Additional interfaces

Transformer

A standard representation of a comonad transformer. (It is likely that not all transformers respect this interface)

module type TRANSFORMER = sig ... end
OCaml

Innovation. Community. Security.