Module Maki.Value

module Value: sig .. end

type 'a ops = {
   descr : string;
   serialize : [ `Fast of 'a -> Bencode.t | `Slow of 'a -> Bencode.t Lwt.t ];
   unserialize : Bencode.t -> 'a Maki.or_error;
}
val make : serialize:[ `Fast of 'a -> Bencode.t | `Slow of 'a -> Bencode.t Lwt.t ] ->
unserialize:(Bencode.t -> 'a Maki.or_error) -> string -> 'a ops
val make_fast : serialize:('a -> Bencode.t) ->
unserialize:(Bencode.t -> 'a Maki.or_error) -> string -> 'a ops
val make_slow : serialize:('a -> Bencode.t Lwt.t) ->
unserialize:(Bencode.t -> 'a Maki.or_error) -> string -> 'a ops
val serialize : 'a ops -> 'a -> Bencode.t Lwt.t
val unserialize : 'a ops -> Bencode.t -> 'a Maki.or_error
val to_string : 'a ops -> 'a -> string Lwt.t
val of_string : 'a ops -> string -> 'a Maki.or_error
val int : int ops
val string : string ops
val bool : bool ops
val float : float ops
val list : 'a ops -> 'a list ops
val assoc : 'a ops -> (string * 'a) list ops
val map : ?descr:string ->
('a -> 'b) -> ('b -> 'a) -> 'b ops -> 'a ops
map f g op encodes x using op.encode (f x), and decodes y by g (op.decode y)
descr : optional description, otherwise op.descr is used
val file : Maki.path ops
A reference to some file content. This should be compared by hash of the file content
val program : Maki.program ops
A reference to some program in the path. This will be turned into an absolute file path first, then handled same as Maki.Value.file
val set : 'a ops -> 'a list ops
set op is similar to Maki.Value.list, except the order of elements does not matter.
val marshal : string -> 'a ops
Use Marshal to store and retrieve data. Caution, this is somewhat unsafe, but useful for quick-and-dirty work.
val pair : 'a ops -> 'b ops -> ('a * 'b) ops
val triple : 'a ops ->
'b ops -> 'c ops -> ('a * 'b * 'c) ops
val quad : 'a ops ->
'b ops ->
'c ops -> 'd ops -> ('a * 'b * 'c * 'd) ops

Universal type for Values

type t = 
| Value : 'a ops * 'a -> t
val argv0 : t
Value corresponding to the program Sys.argv.(0)
val pack : 'a ops -> 'a -> t
val pack_int : int -> t
val pack_string : string -> t
val pack_bool : bool -> t
val pack_file : Maki.path -> t
val pack_list : 'a ops -> 'a list -> t
val pack_program : Maki.program -> t
val pack_set : 'a ops -> 'a list -> t
val pack_assoc : 'a ops -> (string * 'a) list -> t