package timed
Install
Dune Dependency
Authors
Maintainers
Sources
md5=06106626006450f41f0c4d4fcbcf95d0
sha512=b136d79e6ad1a50c811acadc0ae0be049f2dc0d6fc87d233400d602cdf8c6dab3af87557e8f8d740f6eba4b87b9d5b2fcc7e550d24e4ba8c03237573da5623d5
doc/timed.compat/Timed_compat/index.html
Module Timed_compat
Source
Timed references for Stdlib.ref
. This module redefines the all the functions used to update references, and enables the restoration of saved reference states.
Note that this module allocates one blocks of memory at initialization for its internal state. It occupies a total of four words.
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.
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.
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.
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
.