Imperative_state.MakeFunctor building an implementation of IMPERATIVE_STATE for a given type of states.
module State : sig ... endtype state = State.statetraverse_list state f [x1; x2; ...; xn] is [y1; y2; ...; yn] where yi = f state xi, and y1, y2, ..., yn are computed in order, meaning that y1 is computed first, then y2, etc.
iter_list state f [x1; x2; ...; xn] is f state x1; f state x2; ...; f state xn.
traverse_reverse_list state f [x1; x2; ...; xn] is [y1; y2; ...; yn] where yi = f state xi, and y1, y2, ..., yn are computed in reverse order, meaning that yn is computed first, then y(n-1), etc.
iter_rev_list state f [x1; x2; ...; xn] is f state xn; f state x(n-1); ...; f state x1.