Maki deals with functions that return values of any type that provides a 'a Codec.t implementation; that is, values that we can serialize and unserialize. The reason is that values are stored on disk for memoization purposes.
type 'a t
=
{
descr : string; | |
encode : 'a ‑> encoded_value * hash list; | (** |
decode : encoded_value ‑> 'a or_error; | (** Decode the main value from its serialized representation *) |
}
val make : encode:('a ‑> encoded_value * hash list) ‑> decode:(encoded_value ‑> 'a or_error) ‑> string ‑> 'a t
val make_leaf : encode:('a ‑> encoded_value) ‑> decode:(encoded_value ‑> 'a or_error) ‑> string ‑> 'a t
Encode an atomic value, as a leaf of the dependency graph. The value cannot depend on any other value (see make for that)
val encode : 'a t ‑> 'a ‑> encoded_value * hash list
encode codec x
uses the codec
to encode x
into a string that
can be persisted to some Storage.
It also returns the list of hashes of other values this one
depends on
val decode : 'a t ‑> encoded_value ‑> 'a or_error
decode codec s
tries to decode the string s
using codec
into a proper value
val make_bencode : encode:('a ‑> Bencode.t * hash list) ‑> decode:(Bencode.t ‑> 'a or_error) ‑> string ‑> 'a t
Encode via a conversion to Bencode
val make_leaf_bencode : encode:('a ‑> Bencode.t) ‑> decode:(Bencode.t ‑> 'a or_error) ‑> string ‑> 'a t
Encode a leaf via bencode
val int : int t
val string : string t
val bool : bool t
val float : float t
val marshal : string ‑> 'a t
marshal descr
encodes and decodes using marshal.
Unsafe, but useful for prototyping.