Timed references for imperative state
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests
.gitignore
.travis.yml
DESCR
GNUmakefile
LICENSE
README.md
timed.ml
timed.mli
timed_compat.ml
timed_compat.mli

README.md

Timed references for imperative state

This minimal library allows the encapsulation of reference updates in an abstract notion of state. It can be used to emulate a pure interface while working with references.

Authors: Rodolphe Lepigre & Christophe Raffalli

Installation

The library has no dependency, but it requires ocamlfind for installation. You can use the following commands to compile and install.

make
make install

The command make automatically produces the (ocamldoc format) documentation, which contains the same information as timed.mli. It can be visualized by opening the file doc/index.html using a web browser.

Example

open Timed

let _ =
  let r1 = ref 0  in
  let r2 = ref 42 in

  let t1 = Time.save () in

  r1 := 73;

  let t2 = Time.save () in

  Time.restore t1;
  assert(!r1 = 0 && !r2 = 42)
  
  r1 := 17;

  Time.restore t2;
  assert(!r1 = 73 && !r2 = 42)