Module E_ACSL.Monad_rws

This is an implementation the RWS monad. It is a monad to model computations with side-effects and environments in a purely functional and a safe manner. RWS stands for Reader, Writer, State.

The RWS monad is especially useful when implementing a compiler in a purely functional fashion. It offers a clean approach, when one wants to descend recursively into a term structure with the main result being the transformed term, where an environment needs to be maintained (Reader), some additional initialisation statements are generated along the way (Writer), and where some part of the environment has more complex semantics than a simple read-and-forget approach.

module type Conf = sig ... end

specification for building a RWS monad using the Make functor

module type S = sig ... end

module type of an RWS monad

module Make (C : Conf) : S with type out = C.out and type env = C.env and type state = C.state

create an RWS monad from specification C