package travesty

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include Base.Monad.S2
type ('a, 'e) t
val (>>=) : ('a, 'e) t -> ('a -> ('b, 'e) t) -> ('b, 'e) t
val (>>|) : ('a, 'e) t -> ('a -> 'b) -> ('b, 'e) t
module Let_syntax : sig ... end
module Monad_infix : sig ... end
val bind : ('a, 'e) t -> f:('a -> ('b, 'e) t) -> ('b, 'e) t
val map : ('a, 'e) t -> f:('a -> 'b) -> ('b, 'e) t
val join : (('a, 'e) t, 'e) t -> ('a, 'e) t
val ignore_m : ('a, 'e) t -> (unit, 'e) t
val all : ('a, 'e) t list -> ('a list, 'e) t
val all_unit : (unit, 'e) t list -> (unit, 'e) t
include Generic with type ('a, 's) t := ('a, 's) t and type 's state := 's
include Generic_builders with type 'a final := 'a with type ('a, 's) t := ('a, 's) t with type 's state := 's
include Generic_types with type 'a final := 'a with type ('a, 's) t := ('a, 's) t with type 's state := 's
val make : ('s -> 's * 'a) -> ('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 -> 'a) -> ('a, 's) t

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

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

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

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

return lifts a value or monad into a stateful computation.

module Inner : Base.Monad.S

Inner is the monad to which we're adding state.

State transformers have the same runner signatures as state monads, but lifted into the inner monad.

include Generic_runners with type ('a, 's) t := ('a, 's) t and type 'a final := 'a Inner.t and type 's state := 's
include Generic_types with type ('a, 's) t := ('a, 's) t with type 'a final := 'a Inner.t with type 's state := 's
val run' : ('a, 's) t -> 's -> ('s * 'a) Inner.t

run' unfolds a t into a function from context to final state and result.

val run : ('a, 's) t -> 's -> 'a Inner.t

run unfolds a t into a function from context to final result. To get the final context, use run' or call peek at the end of the computation.

include Fix with type ('a, 's) t := ('a, 's) t
val fix : f:(('a -> ('a, 's) t) -> 'a -> ('a, 's) t) -> 'a -> ('a, 's) t

fix ~f init builds a fixed point on f.

At each step, f is passed a continuation mu and a value a. It may choose to return a recursive application of mu, or some value derived from a.

To begin with, f is applied to mu and init.

module Monadic : Generic_builders with type 'a state := 'a and type 'a final := 'a Inner.t and type ('a, 's) t := ('a, 's) t

Monadic contains a version of the builder interface that can interact with the inner monad (Inner) this state transformer is overlaying.

OCaml

Innovation. Community. Security.