package travesty

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

Generic_builders contains generic versions of the 'builder' functions common to all state monad signatures.

include Generic_types
type ('a, 's) t

t is the type of the state monad.

type 'a final

final is the type of returned results. In transformers, this becomes 'a Inner.t; otherwise, it becomes just 'a.

type 's state

state is the type used to represent the state outside of its monad. In S, 's state becomes x for some type x; in S2, 's state becomes 's.

val make : ('s state -> ('s state * 'a) final) -> ('a, 's) t

make creates a context-sensitive computation that can modify both the current context and the data passing through.

Specialised builders

val peek : ('s state -> 'a final) -> ('a, 's) t

peek creates a context-sensitive computation that can look at the current context, but not modify it.

val modify : ('s state -> 's state final) -> (Base.unit, 's) t

modify creates a context-sensitive computation that can look at and modify the current context.

val return : 'a final -> ('a, 's) t

return lifts a value or monad into a stateful computation.