package monadlib

  1. Overview
  2. Docs

Monads with additional structure.

  • author Phil Scott
Base Modules
module type Monoid = sig ... end
module type BasePlus = sig ... end

Monads with additional monoid structure.

module type BaseLazyPlus = sig ... end

LazyPlus provides a plus operation which is non-strict in its second argument.

module type Writer = sig ... end

A writer allows an additional output value to be written during computations and accumulated into a final result.

module type BaseCollectionM = sig ... end

Monads for collections.

Library Types
module type Monad = sig ... end

Library functions for monads.

module type MonadPlus = sig ... end

Library functions for monads with additional structure..

module type LazyPlus = sig ... end

Library functions for lazy monads.

module type Stream = sig ... end

Streams supporting unbounded search. Technically, all streams should be infinite, but for efficiency, we allow them to be truncated. As such, it is impossible to define a general null predicate for streams. Here, we have null return true for the particular case that the stream is an empty list.

module type StreamC = sig ... end

Streams whose generations are themselves collections

Library Creation
module Make (M : BatInterfaces.Monad) : Monad with type 'a m = 'a M.m

Monad library.

module MakePlus (M : BasePlus) : MonadPlus with type 'a m = 'a M.m

MonadPlus library.

module MakeLazyPlus (M : BaseLazyPlus) : LazyPlus with type 'a m = 'a M.m

LazyPlus library.

Defined Monads

module LazyM : BatInterfaces.Monad with type 'a m = 'a Stdlib.Lazy.t
module Lazyt (M : BatInterfaces.Monad) : BatInterfaces.Monad with type 'a m = 'a Stdlib.Lazy.t M.m
module List : BasePlus with type 'a m = 'a list
module LazyListM : BaseLazyPlus with type 'a m = 'a LazyList.t
module Option : BasePlus with type 'a m = 'a option
module State (T : sig ... end) : sig ... end
module MakeWriter (M : Monoid) : sig ... end

A writer which combines the output values using some plus operation.

Transformers
module Listt (M : BatInterfaces.Monad) : BatInterfaces.Monad with type 'a m = 'a list M.m

List monad transformer.

module Optiont (M : BatInterfaces.Monad) : BatInterfaces.Monad with type 'a m = 'a option M.m

Option monad transformer

module Statet (T : sig ... end) (M : BatInterfaces.Monad) : sig ... end

State monad transformer

module Writert (W : Writer) (M : BatInterfaces.Monad) : sig ... end

A monad transformer for Writer.

module MakeStream (M : sig ... end) : sig ... end

The plus operation of the inner monoid should be i commutative, or alternatively, values should only be extracted by an embedding into a commutative monoid such as sort.

module MakeStreamC (M : sig ... end) : sig ... end

Creation of a stream with underlying type 'a CollectionM.m.

module CollectionOpt (C : BaseCollectionM) : sig ... end

Transformer allowing optional values in a collection.

module CollectionWriter (W : sig ... end) (C : BaseCollectionM) : sig ... end

Transformer for writing data inside a collection.

module CollectionState (T : sig ... end) (C : BaseCollectionM) : sig ... end

State inside a collection.

OCaml

Innovation. Community. Security.