From dedcc574fb5707da6dee8096406c4631b5b46342 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 28 Sep 2014 17:23:06 +0200 Subject: [PATCH] a few more combinators in Sexp --- misc/sexp.ml | 2 ++ misc/sexp.mli | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/misc/sexp.ml b/misc/sexp.ml index cd81626b..23cad624 100644 --- a/misc/sexp.ml +++ b/misc/sexp.ml @@ -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] diff --git a/misc/sexp.mli b/misc/sexp.mli index c1f05b9d..6e755918 100644 --- a/misc/sexp.mli +++ b/misc/sexp.mli @@ -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