package b0

  1. Overview
  2. Docs

Lazy immutable stores.

These stores provide access to immutable, lazily determined, typed key-value bindings.

The value of a key in a store is defined either:

  • Explicitly when the store is created.
  • Lazily on the first key access via a fiber specified at key creation time.

Once determined the value of a key in the store never changes.

XXX. Maybe move that at the B0 level.

Stores

type 'a key

The type for keys binding values of type 'a.

type binding =
  1. | B : 'a key * 'a -> binding

The type for store bindings. A key and its value.

type t

The type for stores.

val create : Memo.t -> dir:B00_std.Fpath.t -> binding list -> t

create memo ~dir bs is a store with predefined bindings bs. If a key is mentioned more than once in bs the last binding takes over. The store uses memo to determine other keys as needed. dir is a scratch directory used by key fibers to write memoized file outputs.

val memo : t -> Memo.t

memo s is s's memo as given on create.

val dir : t -> B00_std.Fpath.t

dir s is the scratch directory of s. Key fibers using this directory to write files should do so using nice file name prefixes (e.g. lowercased module or lib names) to avoid name clashes.

val key : ?mark:string -> (t -> Memo.t -> 'a Memo.fiber) -> 'a key

key ~mark det is a new key whose value is determined on access by the fiber:

det s (Memo.with_mark mark (Store.memo s))

mark defaults to "".

val get : t -> 'a key -> 'a Memo.fiber

get s k is the value bound to k in s.

OCaml

Innovation. Community. Security.