Module Timed

Undoable references

This module provides alternative functions for updating references (that is, terms of type 'a ref) and enables the restoration of a previously saved state by "undoing" the updates.

module Time : sig ... end
val (:=) : 'a Stdlib.ref -> 'a -> unit

This function can be used to update a reference, which recording the changes. This is done transparently, so this function can be used as the usual update function.

val incr : int Stdlib.ref -> unit

Incrementation function for a reference of type int. The update is again transparently recorded.

val decr : int Stdlib.ref -> unit

Same as incr, but decrements the int.

val pure_apply : ('a -> 'b) -> 'a -> 'b

Apply the given function to the given argument while taking care of rolling back possible changes to the state of references.

val pure_test : ('a -> bool) -> 'a -> bool

Apply the given test function to the given argument and rollback possible changes ONLY if the value false is returned.