Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
A type of elements, also known as references.
Operations for creating a new reference, reading and writing a reference, and testing whether two references are equivalent. (Two references are considered equivalent after they have been merged by union
.)
val make : 'a -> 'a elem
val get : 'a elem -> 'a
val set : 'a elem -> 'a -> unit
union x y
does nothing if the references x
and y
are equal, and merges them if they are distinct. In the latter case, the content of the merged reference is arbitrarily chosen to be the previous content of x
or y
.
find x
returns the representative element of x
's equivalence class.
Instead of hard-coding the use of mutable state, we parameterize the module over an implementation S
of stores, as described by the signature STORE
. This allows the client to choose between many different representations of the store: e.g., based on primitive references, based on a (possibly extensible) primitive array, based on a persistent map, based on a persistent or semi-persistent array, based on transactional references, etc.
The signature provided by this module is also STORE
, extended with an operation for merging two references.
module type STORE = sig ... end
module StoreMap : sig ... end
This module offers an implementation of STORE
based on immutable integer maps. The stores thus obtained are persistent.
module StoreRef : sig ... end
This module offers an implementation of STORE
based on mutable references.
module StoreTransactionalRef : sig ... end
This module offers an implementation of STORE
based on a simple form of mutable transactional references.
module StoreVector : sig ... end
This module offers an implementation of STORE
based on a single mutable extensible array.