From 05705c7a79e3a17383e3d66f9d3dc94ab8e80619 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2018 18:53:42 +0300 Subject: [PATCH] Move combinators to sexp_intf Signed-off-by: Rudi Grinberg --- src/stdune/sexp.ml | 17 ----------------- src/stdune/sexp.mli | 32 ++------------------------------ src/stdune/sexp_intf.ml | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 47 deletions(-) create mode 100644 src/stdune/sexp_intf.ml diff --git a/src/stdune/sexp.ml b/src/stdune/sexp.ml index b3817f71..dc829199 100644 --- a/src/stdune/sexp.ml +++ b/src/stdune/sexp.ml @@ -1,22 +1,5 @@ include Usexp -module type Combinators = sig - type 'a t - val unit : unit t - val string : string t - val int : int t - val float : float t - val bool : bool t - val pair : 'a t -> 'b t -> ('a * 'b) t - val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t - val list : 'a t -> 'a list t - val array : 'a t -> 'a array t - val option : 'a t -> 'a option t - val string_set : String.Set.t t - val string_map : 'a t -> 'a String.Map.t t - val string_hashtbl : 'a t -> (string, 'a) Hashtbl.t t -end - module To_sexp = struct type nonrec 'a t = 'a -> t let unit () = List [] diff --git a/src/stdune/sexp.mli b/src/stdune/sexp.mli index 0d03211d..cda7719c 100644 --- a/src/stdune/sexp.mli +++ b/src/stdune/sexp.mli @@ -1,36 +1,8 @@ include module type of struct include Usexp end with module Loc := Usexp.Loc -module type Combinators = sig - type 'a t - val unit : unit t - - val string : string t - (** Convert an [Atom] or a [Quoted_string] from/to a string. *) - - val int : int t - val float : float t - val bool : bool t - val pair : 'a t -> 'b t -> ('a * 'b) t - val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t - val list : 'a t -> 'a list t - val array : 'a t -> 'a array t - val option : 'a t -> 'a option t - - val string_set : String.Set.t t - (** [atom_set] is a conversion to/from a set of strings representing atoms. *) - - val string_map : 'a t -> 'a String.Map.t t - (** [atom_map conv]: given a conversion [conv] to/from ['a], returns - a conversion to/from a map where the keys are atoms and the - values are of type ['a]. *) - - val string_hashtbl : 'a t -> (string, 'a) Hashtbl.t t - (** [atom_hashtbl conv] is similar to [atom_map] for hash tables. *) -end - module To_sexp : sig type sexp = t - include Combinators with type 'a t = 'a -> t + include Sexp_intf.Combinators with type 'a t = 'a -> t val record : (string * sexp) list -> sexp @@ -184,7 +156,7 @@ module Of_sexp : sig val record : 'a fields_parser -> 'a t (** Consume the next element of the input as a string, int, char, ... *) - include Combinators with type 'a t := 'a t + include Sexp_intf.Combinators with type 'a t := 'a t (** Unparsed next element of the input *) val raw : ast t diff --git a/src/stdune/sexp_intf.ml b/src/stdune/sexp_intf.ml new file mode 100644 index 00000000..8a66db40 --- /dev/null +++ b/src/stdune/sexp_intf.ml @@ -0,0 +1,16 @@ +module type Combinators = sig + type 'a t + val unit : unit t + val string : string t + val int : int t + val float : float t + val bool : bool t + val pair : 'a t -> 'b t -> ('a * 'b) t + val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t + val list : 'a t -> 'a list t + val array : 'a t -> 'a array t + val option : 'a t -> 'a option t + val string_set : String.Set.t t + val string_map : 'a t -> 'a String.Map.t t + val string_hashtbl : 'a t -> (string, 'a) Hashtbl.t t +end