Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
State.SSourceSignatures of read effects.
include Paramval get : unit -> stateget () reads the current state.
val set : state -> unitset x makes x the new state.
modify f applies f to the current state and then set the result as the new state.
val run : init:state -> (unit -> 'a) -> 'arun t runs the thunk t which may perform state effects.
val register_printer : ([ `Get | `Set of state ] -> string option) -> unitregister_printer p registers a printer p via Printexc.register_printer to convert unhandled internal effects into strings for the OCaml runtime system to display. Ideally, all internal effects should have been handled by run and there is no need to use this function, but when it is not the case, this function can be helpful for debugging. The functor State.Make always registers a simple printer to suggest using run, but you can register new ones to override it. The return type of the printer p should return Some s where s is the resulting string, or None if it chooses not to convert a particular effect. The registered printers are tried in reverse order until one of them returns Some s for some s; that is, the last registered printer is tried first. Note that this function is a wrapper of Printexc.register_printer and all the registered printers (via this function or Printexc.register_printer) are put into the same list.
The input type of the printer p is a variant representation of the internal effects used in this module. They correspond to the effects trigger by get and set. More precisely,
`Get corresponds to the effect triggered by get ().`Set state corresponds to the effect triggered by set state.