package timed

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Timed_compatSource

Timed references for Stdlib.ref. This module redefines the all the functions used to update references, and enables the restoration of saved reference states.

  • author Christophe Raffalli
  • author Rodolphe Lepigre

Note that this module allocates one blocks of memory at initialization for its internal state. It occupies a total of four words.

Sourceval (:=) : 'a ref -> 'a -> unit

r := v sets the value of the reference r to v. This operation has a very small overhead compared to Stdlib.((:=)) if no time has been via Time.save. Nonetheless, it is always constant time, and allocation is only necessary if the current “time” is accessible (or not reclaimed by the garbage-collector). When that is the case, three blocks of memory are allocated, for a total of eight words.

Sourceval incr : int ref -> unit

incr r is equivalent to r := !r + 1.

Sourceval decr : int ref -> unit

decr r is equivalent to r := !r - 1.

Sourcemodule Time : sig ... end

The Time module provides an abstract representation of time, used to set a point from which (monitored) updates to references are recorded to allow undoing/redoing the corresponding changes.

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

pure_apply f v computes the result of f v, but reverts the (monitored) updates made to references in the process before returning the value.

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

pure_test p v applies the predicate p to v (i.e., compute p v) and returns the result, reverting (monitored) updates made to reference if the result is false. Updates are preserved if the result is true.

OCaml

Innovation. Community. Security.