Skip to main content

Module comonad

Module comonad 

Source
Expand description

Comonads, the dual of monads, combining Extend and Extract.

A Comonad is a type that supports both extracting a value from a context (Extract) and extending a local computation to the whole context (Extend). It is the categorical dual of Monad: where Monad composes Pointed + Semimonad, Comonad composes Extract + Extend.

This module is a port of PureScript’s Control.Comonad.

§Hierarchy

Functor
  |
  +-- Extract              (extract :: F<A> -> A; no Functor constraint)
  |
  +-- Extend: Functor      (extend :: (F<A> -> B) -> F<A> -> F<B>)
  |
  +-- Comonad: Extend + Extract   (blanket impl, no new methods)

Traits§

Comonad
A type class for comonads, combining Extend and Extract.