mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 03:35:30 -05:00
a few more combinators in Sexp
This commit is contained in:
parent
5cb2bb3538
commit
dedcc574fb
2 changed files with 5 additions and 1 deletions
|
|
@ -45,8 +45,10 @@ let of_bool x = Atom (string_of_bool x)
|
|||
let of_string x = Atom x
|
||||
let of_unit = List []
|
||||
let of_list l = List l
|
||||
let of_rev_list l = List (List.rev l)
|
||||
let of_pair (x,y) = List[x;y]
|
||||
let of_triple (x,y,z) = List[x;y;z]
|
||||
let of_quad (x,y,z,u) = List[x;y;z;u]
|
||||
|
||||
let of_variant name args = List (Atom name :: args)
|
||||
let of_field name t = List [Atom name; t]
|
||||
|
|
|
|||
|
|
@ -44,15 +44,17 @@ val hash : t -> int
|
|||
val of_int : int -> t
|
||||
val of_bool : bool -> t
|
||||
val of_list : t list -> t
|
||||
val of_rev_list : t list -> t (** Reverse the list *)
|
||||
val of_string : string -> t
|
||||
val of_float : float -> t
|
||||
val of_unit : t
|
||||
val of_pair : t * t -> t
|
||||
val of_triple : t * t * t -> t
|
||||
val of_quad : t * t * t * t -> t
|
||||
|
||||
val of_variant : string -> t list -> t
|
||||
(** [of_variant name args] is used to encode algebraic variants
|
||||
into a S-expr. For instance [of_variant "some" (of_int 1)]
|
||||
into a S-expr. For instance [of_variant "some" [of_int 1]]
|
||||
represents the value [Some 1] *)
|
||||
|
||||
val of_field : string -> t -> t
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue