package travesty
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=40ada5c475cfeba7d933eec133294d1b5ef5da6ce864c9746b2ce4ce49b5e3a4
md5=dc818d6b232f13edb388d25781cd99a2
doc/travesty/Travesty/State/module-type-S2/index.html
Module type State.S2
Source
S2
is the signature of state monads parametrised over both value and state types.
include Generic
with type ('a, 's) t := ('a, 's) t
and type 's state := 's
and type 'a final := 'a
State monads share the signatures of their builder functions with state transformers...
include State_transform_intf.Generic_builders
with type ('a, 's) t := ('a, 's) t
with type 's state := 's
with type 'a final := 'a
include State_transform_intf.Generic_types
with type ('a, 's) t := ('a, 's) t
with type 's state := 's
with type 'a final := 'a
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.
...as well as their runner functions...
include State_transform_intf.Generic_runners
with type ('a, 's) t := ('a, 's) t
and type 'a final := 'a
and type 's state := 's
include State_transform_intf.Generic_types
with type ('a, 's) t := ('a, 's) t
with type 'a final := 'a
with type 's state := 's
val run' : ('a, 's) t -> 's -> 's * 'a
run'
unfolds a t
into a function from context to final state and result.
val run : ('a, 's) t -> 's -> 'a
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.
...and fixed-point combinators.