diff --git a/src/build.ml b/src/build.ml index 4630ae5f..757cfefb 100644 --- a/src/build.ml +++ b/src/build.ml @@ -60,8 +60,8 @@ module Repr = struct | G_evaluated l -> l | G_unevaluated (loc, path, _) -> Exn.code_error "Build.get_glob_result_exn: got unevaluated" - [ "loc", Loc.sexp_of_t loc - ; "path", Path.sexp_of_t path ] + [ "loc", Loc.to_sexp loc + ; "path", Path.to_sexp path ] end include Repr let repr t = t diff --git a/src/build_interpret.ml b/src/build_interpret.ml index bab0e03d..56dbcd39 100644 --- a/src/build_interpret.ml +++ b/src/build_interpret.ml @@ -188,7 +188,7 @@ let targets = match loop a [], loop b [] with | [], [] -> acc | a, b -> - let targets x = Path.Set.sexp_of_t (Target.paths x) in + let targets x = Path.Set.to_sexp (Target.paths x) in Exn.code_error "Build_interpret.targets: cannot have targets \ under a [if_file_exists]" [ "targets-a", targets a @@ -231,7 +231,7 @@ module Rule = struct match loc with | None -> Exn.code_error "rule has targets in different directories" - [ "targets", Sexp.To_sexp.list Path.sexp_of_t + [ "targets", Sexp.To_sexp.list Path.to_sexp (List.map targets ~f:Target.path) ] | Some loc -> diff --git a/src/build_system.ml b/src/build_system.ml index f719c546..c2a6a300 100644 --- a/src/build_system.ml +++ b/src/build_system.ml @@ -234,7 +234,7 @@ module Alias0 = struct if not (Path.is_in_build_dir dir) || String.contains name '/' then Exn.code_error "Alias0.make: Invalid alias" [ "name", Sexp.To_sexp.string name - ; "dir", Path.sexp_of_t dir + ; "dir", Path.to_sexp dir ]; { dir; name } @@ -462,7 +462,7 @@ let entry_point t ~f = | stack -> Exn.code_error "Build_system.entry_point: called inside the rule generator callback" - ["stack", Sexp.To_sexp.list Path.sexp_of_t stack] + ["stack", Sexp.To_sexp.list Path.to_sexp stack] ); f () @@ -1536,8 +1536,8 @@ let get_collector t ~dir = "Build_system.get_collector called on external directory" else "Build_system.get_collector called on closed directory") - [ "dir", Path.sexp_of_t dir - ; "load_dir_stack", Sexp.To_sexp.list Path.sexp_of_t t.load_dir_stack + [ "dir", Path.to_sexp dir + ; "load_dir_stack", Sexp.To_sexp.list Path.to_sexp t.load_dir_stack ] let add_rule t (rule : Build_interpret.Rule.t) = @@ -1558,7 +1558,7 @@ let prefix_rules t prefix ~f = | [] -> () | targets -> Exn.code_error "Build_system.prefix_rules' prefix contains targets" - ["targets", Path.Set.sexp_of_t (Build_interpret.Target.paths targets)] + ["targets", Path.Set.to_sexp (Build_interpret.Target.paths targets)] end; let prefix = match t.prefix with diff --git a/src/context.ml b/src/context.ml index 20c97340..2082bcdd 100644 --- a/src/context.ml +++ b/src/context.ml @@ -11,7 +11,7 @@ module Kind = struct end type t = Default | Opam of Opam.t - let sexp_of_t : t -> Sexp.t = function + let to_sexp : t -> Sexp.t = function | Default -> Sexp.To_sexp.string "default" | Opam o -> Sexp.To_sexp.(record [ "root" , string o.root @@ -86,12 +86,12 @@ type t = ; which_cache : (string, Path.t option) Hashtbl.t } -let sexp_of_t t = +let to_sexp t = let open Sexp.To_sexp in - let path = Path.sexp_of_t in + let path = Path.to_sexp in record [ "name", string t.name - ; "kind", Kind.sexp_of_t t.kind + ; "kind", Kind.to_sexp t.kind ; "profile", string t.profile ; "merlin", bool t.merlin ; "for_host", option string (Option.map t.for_host ~f:(fun t -> t.name)) @@ -103,16 +103,16 @@ let sexp_of_t t = ; "ocamlopt", option path t.ocamlopt ; "ocamldep", path t.ocamldep ; "ocamlmklib", path t.ocamlmklib - ; "env", Env.sexp_of_t (Env.diff t.env Env.initial) + ; "env", Env.to_sexp (Env.diff t.env Env.initial) ; "findlib_path", list path (Findlib.path t.findlib) ; "arch_sixtyfour", bool t.arch_sixtyfour ; "natdynlink_supported", bool (Dynlink_supported.By_the_os.get t.natdynlink_supported) ; "supports_shared_libraries", bool (Dynlink_supported.By_the_os.get t.supports_shared_libraries) - ; "opam_vars", Hashtbl.sexp_of_t string string t.opam_var_cache - ; "ocaml_config", Ocaml_config.sexp_of_t t.ocaml_config - ; "which", Hashtbl.sexp_of_t string (option path) t.which_cache + ; "opam_vars", Hashtbl.to_sexp string string t.opam_var_cache + ; "ocaml_config", Ocaml_config.to_sexp t.ocaml_config + ; "which", Hashtbl.to_sexp string (option path) t.which_cache ] let compare a b = compare a.name b.name diff --git a/src/context.mli b/src/context.mli index 738e96dc..f81571a5 100644 --- a/src/context.mli +++ b/src/context.mli @@ -128,7 +128,7 @@ type t = ; which_cache : (string, Path.t option) Hashtbl.t } -val sexp_of_t : t -> Sexp.t +val to_sexp : t -> Sexp.t (** Compare the context names *) val compare : t -> t -> Ordering.t diff --git a/src/dir_contents.ml b/src/dir_contents.ml index 25084014..57a8cc62 100644 --- a/src/dir_contents.ml +++ b/src/dir_contents.ml @@ -281,8 +281,8 @@ let mlds t (doc : Documentation.t) = | Some x -> x | None -> Exn.code_error "Dir_contents.mlds" - [ "doc", Loc.sexp_of_t doc.loc - ; "available", Sexp.To_sexp.(list Loc.sexp_of_t) + [ "doc", Loc.to_sexp doc.loc + ; "available", Sexp.To_sexp.(list Loc.to_sexp) (List.map map ~f:(fun (d, _) -> d.Documentation.loc)) ] diff --git a/src/dsexp/dsexp.ml b/src/dsexp/dsexp.ml index 635d717d..cd56265a 100644 --- a/src/dsexp/dsexp.ml +++ b/src/dsexp/dsexp.ml @@ -853,9 +853,9 @@ module type Sexpable = sig val dgen : t To_sexp.t end -let rec sexp_of_t = function +let rec to_sexp = function | Atom (A a) -> Sexp.Atom a - | List s -> List (List.map s ~f:sexp_of_t) + | List s -> List (List.map s ~f:to_sexp) | Quoted_string s -> Sexp.Atom s | Template t -> List diff --git a/src/dsexp/dsexp.mli b/src/dsexp/dsexp.mli index 9567fa07..65aa565b 100644 --- a/src/dsexp/dsexp.mli +++ b/src/dsexp/dsexp.mli @@ -403,7 +403,7 @@ module type Sexpable = sig val dgen : t To_sexp.t end -val sexp_of_t : t Sexp.To_sexp.t +val to_sexp : t Sexp.To_sexp.t module Io : sig val load : ?lexer:Lexer.t -> Path.t -> mode:'a Parser.Mode.t -> 'a diff --git a/src/dune_file.ml b/src/dune_file.ml index 0ab7a522..d9f89c76 100644 --- a/src/dune_file.ml +++ b/src/dune_file.ml @@ -363,7 +363,7 @@ module Bindings = struct Dsexp.List (Dsexp.atom (":" ^ name) :: List.map ~f:dgen bindings)) ) - let sexp_of_t sexp_of_a bindings = + let to_sexp sexp_of_a bindings = Sexp.List ( List.map bindings ~f:(function | Unnamed a -> sexp_of_a a @@ -439,7 +439,7 @@ module Dep_conf = struct | Universe -> Dsexp.unsafe_atom_of_string "universe" - let sexp_of_t t = Dsexp.sexp_of_t (dgen t) + let to_sexp t = Dsexp.to_sexp (dgen t) end module Preprocess = struct diff --git a/src/dune_file.mli b/src/dune_file.mli index e8d5d94c..e14ebc52 100644 --- a/src/dune_file.mli +++ b/src/dune_file.mli @@ -105,7 +105,7 @@ module Bindings : sig val dgen : 'a Dsexp.To_sexp.t -> 'a t Dsexp.To_sexp.t - val sexp_of_t : 'a Sexp.To_sexp.t -> 'a t Sexp.To_sexp.t + val to_sexp : 'a Sexp.To_sexp.t -> 'a t Sexp.To_sexp.t end module Dep_conf : sig @@ -121,7 +121,7 @@ module Dep_conf : sig val remove_locs : t -> t include Dsexp.Sexpable with type t := t - val sexp_of_t : t Sexp.To_sexp.t + val to_sexp : t Sexp.To_sexp.t end module Buildable : sig diff --git a/src/dune_project.ml b/src/dune_project.ml index e73cd855..f7c20feb 100644 --- a/src/dune_project.ml +++ b/src/dune_project.ml @@ -7,7 +7,7 @@ module Kind = struct | Dune | Jbuilder - let sexp_of_t t = + let to_sexp t = Sexp.Atom (match t with | Dune -> "dune" @@ -24,7 +24,7 @@ module Name : sig val to_string_hum : t -> string val dparse : t Dsexp.Of_sexp.t - val sexp_of_t : t Sexp.To_sexp.t + val to_sexp : t Sexp.To_sexp.t val encode : t -> string val decode : string -> t @@ -59,11 +59,11 @@ end = struct | Named s -> s | Anonymous p -> sprintf "" (Path.to_string_maybe_quoted p) - let sexp_of_t = function + let to_sexp = function | Named s -> Sexp.To_sexp.string s | Anonymous p -> List [ Atom "anonymous" - ; Path.sexp_of_t p + ; Path.to_sexp p ] let validate name = @@ -132,10 +132,10 @@ module Project_file = struct ; mutable exists : bool } - let sexp_of_t { file; exists } = + let to_sexp { file; exists } = Sexp.To_sexp.( record - [ "file", Path.sexp_of_t file + [ "file", Path.to_sexp file ; "exists", bool exists ]) end @@ -280,11 +280,11 @@ let key = (fun { name; root; version; project_file; kind ; stanza_parser = _; packages = _ } -> Sexp.To_sexp.record - [ "name", Name.sexp_of_t name - ; "root", Path.Local.sexp_of_t root + [ "name", Name.to_sexp name + ; "root", Path.Local.to_sexp root ; "version", Sexp.To_sexp.(option string) version - ; "project_file", Project_file.sexp_of_t project_file - ; "kind", Kind.sexp_of_t kind + ; "project_file", Project_file.to_sexp project_file + ; "kind", Kind.to_sexp kind ]) let set t = Dsexp.Of_sexp.set key t diff --git a/src/dune_project.mli b/src/dune_project.mli index 29b0146c..e8ed44f2 100644 --- a/src/dune_project.mli +++ b/src/dune_project.mli @@ -23,7 +23,7 @@ module Name : sig (** Convert to a string that is suitable for human readable messages *) val to_string_hum : t -> string - val sexp_of_t : t Sexp.To_sexp.t + val to_sexp : t Sexp.To_sexp.t (** Convert to/from an encoded string that is suitable to use in filenames *) val encode : t -> string diff --git a/src/env.ml b/src/env.ml index e6217cd0..7d2a5fc9 100644 --- a/src/env.ml +++ b/src/env.ml @@ -63,7 +63,7 @@ let extend t ~vars = let extend_env x y = extend x ~vars:y.vars -let sexp_of_t t = +let to_sexp t = let open Sexp.To_sexp in (list (pair string string)) (Map.to_list t.vars) diff --git a/src/env.mli b/src/env.mli index b33c5e8b..c7a15429 100644 --- a/src/env.mli +++ b/src/env.mli @@ -28,6 +28,6 @@ val diff : t -> t -> t val update : t -> var:string -> f:(string option -> string option) -> t -val sexp_of_t : t -> Sexp.t +val to_sexp : t -> Sexp.t val of_string_map : string String.Map.t -> t diff --git a/src/installed_dune_file.ml b/src/installed_dune_file.ml index b6bc53d1..89ad3a72 100644 --- a/src/installed_dune_file.ml +++ b/src/installed_dune_file.ml @@ -103,6 +103,6 @@ let gen ~(dune_version : Syntax.Version.t) confs = | (x, _) when x >= 1 -> "2" | (_, _) -> Exn.code_error "Cannot generate dune with unknown version" - ["dune_version", Syntax.Version.sexp_of_t dune_version]) + ["dune_version", Syntax.Version.to_sexp dune_version]) ; List sexps ] diff --git a/src/lib.ml b/src/lib.ml index abb5f4aa..89ebaa00 100644 --- a/src/lib.ml +++ b/src/lib.ml @@ -583,20 +583,20 @@ let check_private_deps lib ~loc ~allow_private_deps = Ok lib let already_in_table (info : Info.t) name x = - let dgen = Sexp.To_sexp.(pair Path.sexp_of_t string) in + let dgen = Sexp.To_sexp.(pair Path.to_sexp string) in let sexp = match x with | St_initializing x -> Sexp.List [Sexp.Atom "Initializing"; - Path.sexp_of_t x.path] + Path.to_sexp x.path] | St_found t -> List [Sexp.Atom "Found"; - Path.sexp_of_t t.info.src_dir] + Path.to_sexp t.info.src_dir] | St_not_found -> Sexp.Atom "Not_found" | St_hidden (_, { path; reason; _ }) -> List [Sexp.Atom "Hidden"; - Path.sexp_of_t path; Sexp.Atom reason] + Path.to_sexp path; Sexp.Atom reason] in Exn.code_error "Lib_db.DB: resolver returned name that's already in the table" diff --git a/src/main.ml b/src/main.ml index 4dda1845..dbeab71f 100644 --- a/src/main.ml +++ b/src/main.ml @@ -80,7 +80,7 @@ let setup ?(log=Log.no_log) let contexts = List.concat contexts in List.iter contexts ~f:(fun (ctx : Context.t) -> Log.infof log "@[<1>Dune context:@,%a@]@." Sexp.pp - (Context.sexp_of_t ctx)); + (Context.to_sexp ctx)); let rule_done = ref 0 in let rule_total = ref 0 in let gen_status_line () = diff --git a/src/module.ml b/src/module.ml index e160913f..645c2ff6 100644 --- a/src/module.ml +++ b/src/module.ml @@ -12,7 +12,7 @@ module Name = struct let dparse = Dsexp.Of_sexp.string let dgen = Dsexp.To_sexp.string - let sexp_of_t = Sexp.To_sexp.string + let to_sexp = Sexp.To_sexp.string let add_suffix = (^) diff --git a/src/module.mli b/src/module.mli index 2792d041..94dbeb8c 100644 --- a/src/module.mli +++ b/src/module.mli @@ -8,7 +8,7 @@ module Name : sig val add_suffix : t -> string -> t - val sexp_of_t : t Sexp.To_sexp.t + val to_sexp : t Sexp.To_sexp.t val compare : t -> t -> Ordering.t val of_string : string -> t val to_string : t -> string diff --git a/src/ocaml-config/ocaml_config.ml b/src/ocaml-config/ocaml_config.ml index d9eb76b3..9af769e5 100644 --- a/src/ocaml-config/ocaml_config.ml +++ b/src/ocaml-config/ocaml_config.ml @@ -17,7 +17,7 @@ module Value = struct | Words of string list | Prog_and_args of Prog_and_args.t - let sexp_of_t : t -> Sexp.t = + let to_sexp : t -> Sexp.t = let open Sexp.To_sexp in function | Bool x -> bool x @@ -185,13 +185,13 @@ let to_list t : (string * Value.t) list = ; "supports_shared_libraries", Bool t.supports_shared_libraries ] -let sexp_of_t t = +let to_sexp t = let open Sexp in List (to_list t |> List.map ~f:(fun (k, v) -> List [ Atom k - ; Value.sexp_of_t v + ; Value.to_sexp v ])) module Origin = struct diff --git a/src/ocaml-config/ocaml_config.mli b/src/ocaml-config/ocaml_config.mli index 13762df4..31192d43 100644 --- a/src/ocaml-config/ocaml_config.mli +++ b/src/ocaml-config/ocaml_config.mli @@ -8,7 +8,7 @@ open! Stdune contents of [Makefile.config]. *) type t -val sexp_of_t : t Sexp.To_sexp.t +val to_sexp : t Sexp.To_sexp.t module Prog_and_args : sig type t = @@ -106,7 +106,7 @@ module Value : sig val to_string : t -> string - val sexp_of_t : t Sexp.To_sexp.t + val to_sexp : t Sexp.To_sexp.t end val to_list : t -> (string * Value.t) list diff --git a/src/ocamldep.ml b/src/ocamldep.ml index 8527d4d9..09bf7b44 100644 --- a/src/ocamldep.ml +++ b/src/ocamldep.ml @@ -16,10 +16,10 @@ module Dep_graph = struct | Some x -> x | None -> Exn.code_error "Ocamldep.Dep_graph.deps_of" - [ "dir", Path.sexp_of_t t.dir - ; "modules", Sexp.To_sexp.(list Module.Name.sexp_of_t) + [ "dir", Path.to_sexp t.dir + ; "modules", Sexp.To_sexp.(list Module.Name.to_sexp) (Module.Name.Map.keys t.per_module) - ; "module", Module.Name.sexp_of_t m.name + ; "module", Module.Name.to_sexp m.name ] let top_closed t modules = diff --git a/src/ordered_set_lang.ml b/src/ordered_set_lang.ml index ffe71516..6cc5a209 100644 --- a/src/ordered_set_lang.ml +++ b/src/ordered_set_lang.ml @@ -359,8 +359,8 @@ module Unexpanded = struct | None -> Exn.code_error "Ordered_set_lang.Unexpanded.expand" - [ "included-file", Path.sexp_of_t path - ; "files", Sexp.To_sexp.(list Path.sexp_of_t) + [ "included-file", Path.to_sexp path + ; "files", Sexp.To_sexp.(list Path.to_sexp) (Path.Map.keys files_contents) ] in diff --git a/src/promotion.ml b/src/promotion.ml index 6e01af11..e1a75c97 100644 --- a/src/promotion.ml +++ b/src/promotion.ml @@ -7,11 +7,11 @@ module File = struct } (* XXX these sexp converters will be useful for the dump command *) - let _sexp_of_t { src; dst } = + let _to_sexp { src; dst } = Sexp.List - [ Path.sexp_of_t src + [ Path.to_sexp src ; Sexp.Atom "as" - ; Path.sexp_of_t dst + ; Path.to_sexp dst ] let db : t list ref = ref [] diff --git a/src/scope.ml b/src/scope.ml index a7bd03c4..0b67d28a 100644 --- a/src/scope.ml +++ b/src/scope.ml @@ -30,7 +30,7 @@ module DB = struct | None -> if Path.is_root d || not (Path.is_managed d) then Exn.code_error "Scope.DB.find_by_dir got an invalid path" - [ "dir" , Path.sexp_of_t dir + [ "dir" , Path.to_sexp dir ; "context", Sexp.To_sexp.string t.context ]; let scope = loop (Path.parent_exn d) in @@ -44,10 +44,10 @@ module DB = struct | Some x -> x | None -> Exn.code_error "Scope.DB.find_by_name" - [ "name" , Dune_project.Name.sexp_of_t name + [ "name" , Dune_project.Name.to_sexp name ; "context", Sexp.To_sexp.string t.context ; "names", - Sexp.To_sexp.(list Dune_project.Name.sexp_of_t) + Sexp.To_sexp.(list Dune_project.Name.to_sexp) (Project_name_map.keys t.by_name) ] @@ -60,7 +60,7 @@ module DB = struct | Ok x -> x | Error (_name, project1, project2) -> let to_sexp (project : Dune_project.t) = - Sexp.To_sexp.(pair Dune_project.Name.sexp_of_t Path.Local.sexp_of_t) + Sexp.To_sexp.(pair Dune_project.Name.to_sexp Path.Local.to_sexp) (Dune_project.name project, Dune_project.root project) in Exn.code_error "Scope.DB.create got two projects with the same name" diff --git a/src/stdune/hashtbl.ml b/src/stdune/hashtbl.ml index 1f599556..5383fee4 100644 --- a/src/stdune/hashtbl.ml +++ b/src/stdune/hashtbl.ml @@ -88,13 +88,13 @@ let iter t ~f = iter ~f t let keys t = foldi t ~init:[] ~f:(fun key _ acc -> key :: acc) -let sexp_of_t (type key) f g t = +let to_sexp (type key) f g t = let module M = Map.Make(struct type t = key let compare a b = Ordering.of_int (compare a b) end) in - Map.sexp_of_t M.to_list f g + Map.to_sexp M.to_list f g (foldi t ~init:M.empty ~f:(fun key data acc -> M.add acc key data)) diff --git a/src/stdune/hashtbl.mli b/src/stdune/hashtbl.mli index cf27722a..001492be 100644 --- a/src/stdune/hashtbl.mli +++ b/src/stdune/hashtbl.mli @@ -28,4 +28,4 @@ val mem : ('a, _) t -> 'a -> bool val keys : ('a, _) t -> 'a list -val sexp_of_t : ('a -> Sexp.t) -> ('b -> Sexp.t) -> ('a, 'b) t -> Sexp.t +val to_sexp : ('a -> Sexp.t) -> ('b -> Sexp.t) -> ('a, 'b) t -> Sexp.t diff --git a/src/stdune/int.ml b/src/stdune/int.ml index c2e4f901..2d496f46 100644 --- a/src/stdune/int.ml +++ b/src/stdune/int.ml @@ -7,7 +7,7 @@ module T = struct Eq else Gt - let sexp_of_t = Sexp.To_sexp.int + let to_sexp = Sexp.To_sexp.int end include T diff --git a/src/stdune/int.mli b/src/stdune/int.mli index 577146a0..4a001a01 100644 --- a/src/stdune/int.mli +++ b/src/stdune/int.mli @@ -1,6 +1,6 @@ type t = int val compare : t -> t -> Ordering.t -val sexp_of_t : t -> Sexp.t +val to_sexp : t -> Sexp.t module Set : Set.S with type elt = t module Map : Map.S with type key = t diff --git a/src/stdune/loc.ml b/src/stdune/loc.ml index dc5d6149..a38a1e39 100644 --- a/src/stdune/loc.ml +++ b/src/stdune/loc.ml @@ -30,7 +30,7 @@ let sexp_of_position_no_file (p : Lexing.position) = ; "pos_cnum", int p.pos_cnum ] -let sexp_of_t t = +let to_sexp t = let open Sexp.To_sexp in record (* TODO handle when pos_fname differs *) [ "pos_fname", string t.start.pos_fname diff --git a/src/stdune/loc.mli b/src/stdune/loc.mli index 4893079b..20d925fc 100644 --- a/src/stdune/loc.mli +++ b/src/stdune/loc.mli @@ -9,7 +9,7 @@ val none : t val of_lexbuf : Lexing.lexbuf -> t -val sexp_of_t : t -> Sexp.t +val to_sexp : t -> Sexp.t val sexp_of_position_no_file : Lexing.position -> Sexp.t diff --git a/src/stdune/map.ml b/src/stdune/map.ml index 86c43bbc..77ee8e18 100644 --- a/src/stdune/map.ml +++ b/src/stdune/map.ml @@ -144,5 +144,5 @@ module Make(Key : Comparable.S) : S with type key = Key.t = struct union a b ~f:(fun _ _ y -> Some y) end -let sexp_of_t to_list f g t = +let to_sexp to_list f g t = Sexp.To_sexp.(list (pair f g)) (to_list t) diff --git a/src/stdune/map.mli b/src/stdune/map.mli index f3145923..a887620d 100644 --- a/src/stdune/map.mli +++ b/src/stdune/map.mli @@ -2,7 +2,7 @@ module type S = Map_intf.S module Make(Key : Comparable.S) : S with type key = Key.t -val sexp_of_t +val to_sexp : ('a -> ('b * 'c) list) -> 'b Sexp.To_sexp.t -> 'c Sexp.To_sexp.t diff --git a/src/stdune/path.ml b/src/stdune/path.ml index 1c1f5a75..0b348525 100644 --- a/src/stdune/path.ml +++ b/src/stdune/path.ml @@ -34,7 +34,7 @@ let explode_path = module External : sig type t - val sexp_of_t : t Sexp.To_sexp.t + val to_sexp : t Sexp.To_sexp.t val compare : t -> t -> Ordering.t val compare_val : t -> t -> Ordering.t @@ -71,7 +71,7 @@ end = struct [ "t", Sexp.To_sexp.string t ]; make t - let sexp_of_t t = Sexp.To_sexp.string (to_string t) + let to_sexp t = Sexp.To_sexp.string (to_string t) (* let rec cd_dot_dot t = @@ -125,7 +125,7 @@ end module Local : sig type t - val sexp_of_t : t Sexp.To_sexp.t + val to_sexp : t Sexp.To_sexp.t val root : t val is_root : t -> bool @@ -213,12 +213,12 @@ end = struct | exception Not_found -> t | i -> String.sub t ~pos:(i + 1) ~len:(len - i - 1) - let sexp_of_t t = Sexp.To_sexp.string (to_string t) + let to_sexp t = Sexp.To_sexp.string (to_string t) let relative ?error_loc t path = if not (Filename.is_relative path) then ( Exn.code_error "Local.relative: received absolute path" - [ "t", sexp_of_t t + [ "t", to_sexp t ; "path", Sexp.To_sexp.string path ] ); @@ -367,7 +367,7 @@ end = struct let make p = if is_root p then Exn.code_error "Path.Local.Prefix.make" - [ "path", sexp_of_t p ]; + [ "path", to_sexp p ]; let p = to_string p in { len = String.length p ; path = p @@ -398,8 +398,8 @@ let (abs_root, set_root) = | None -> root_dir := Some new_root | Some root_dir -> Exn.code_error "set_root: cannot set root_dir more than once" - [ "root_dir", External.sexp_of_t root_dir - ; "new_root_dir", External.sexp_of_t new_root + [ "root_dir", External.to_sexp root_dir + ; "new_root_dir", External.to_sexp new_root ] in let abs_root = lazy ( @@ -427,7 +427,7 @@ module Kind = struct | Local t -> Local.to_string t | External t -> External.to_string t - let sexp_of_t t = Sexp.To_sexp.string (to_string t) + let to_sexp t = Sexp.To_sexp.string (to_string t) let of_string s = if Filename.is_relative s then @@ -478,8 +478,8 @@ let (build_dir_kind, build_dir_prefix, set_build_dir) = | External _ -> Local.Prefix.invalid) | Some build_dir -> Exn.code_error "set_build_dir: cannot set build_dir more than once" - [ "build_dir", Kind.sexp_of_t build_dir - ; "new_build_dir", Kind.sexp_of_t new_build_dir ] + [ "build_dir", Kind.to_sexp build_dir + ; "new_build_dir", Kind.to_sexp new_build_dir ] in let build_dir = lazy ( match !build_dir with @@ -598,12 +598,12 @@ let of_string ?error_loc s = else make_local_path (Local.of_string s ?error_loc) -let sexp_of_t t = +let to_sexp t = let constr f x y = Sexp.To_sexp.(pair string f) (x, y) in match t with - | In_build_dir s -> constr Local.sexp_of_t "In_build_dir" s - | In_source_tree s -> constr Local.sexp_of_t "In_source_tree" s - | External s -> constr External.sexp_of_t "External" s + | In_build_dir s -> constr Local.to_sexp "In_build_dir" s + | In_source_tree s -> constr Local.to_sexp "In_source_tree" s + | External s -> constr External.to_sexp "External" s let of_filename_relative_to_initial_cwd fn = external_ ( @@ -669,8 +669,8 @@ let append a b = | In_build_dir _ | External _ -> Exn.code_error "Path.append called with directory that's \ not in the source tree" - [ "a", sexp_of_t a - ; "b", sexp_of_t b + [ "a", to_sexp a + ; "b", to_sexp b ] | In_source_tree b -> append_local a b @@ -694,7 +694,7 @@ let parent_exn t = match parent t with | Some p -> p | None -> Exn.code_error "Path.parent:exn t is root" - ["t", sexp_of_t t] + ["t", to_sexp t] let is_strict_descendant_of_build_dir = function | In_build_dir p -> not (Local.is_root p) @@ -755,7 +755,7 @@ let drop_build_context t = let drop_build_context_exn t = match extract_build_context t with - | None -> Exn.code_error "Path.drop_build_context_exn" [ "t", sexp_of_t t ] + | None -> Exn.code_error "Path.drop_build_context_exn" [ "t", to_sexp t ] | Some (_, t) -> t let drop_optional_build_context t = @@ -797,7 +797,7 @@ let explode_exn t = match explode t with | Some s -> s | None -> Exn.code_error "Path.explode_exn" - ["path", sexp_of_t t] + ["path", to_sexp t] let exists t = try Sys.file_exists (to_string t) @@ -852,7 +852,7 @@ let insert_after_build_dir_exn = let error a b = Exn.code_error "Path.insert_after_build_dir_exn" - [ "path" , sexp_of_t a + [ "path" , to_sexp a ; "insert", Sexp.To_sexp.string b ] in @@ -874,7 +874,7 @@ let rm_rf = fun t -> if not (is_managed t) then ( Exn.code_error "Path.rm_rf called on external dir" - ["t", sexp_of_t t] + ["t", to_sexp t] ); let fn = to_string t in match Unix.lstat fn with @@ -885,7 +885,7 @@ let mkdir_p = function | External s -> External.mkdir_p s | In_source_tree s -> Exn.code_error "Path.mkdir_p cannot dir in source" - ["s", Local.sexp_of_t s] + ["s", Local.to_sexp s] | In_build_dir k -> Kind.mkdir_p (Kind.append_local (Lazy.force build_dir_kind) k) @@ -927,7 +927,7 @@ let pp_debug ppf = function module Set = struct include Set.Make(T) - let sexp_of_t t = Sexp.To_sexp.(list sexp_of_t) (to_list t) + let to_sexp t = Sexp.To_sexp.(list to_sexp) (to_list t) let of_string_set ss ~f = String.Set.to_list ss |> List.map ~f diff --git a/src/stdune/path.mli b/src/stdune/path.mli index c56b9214..6880fa24 100644 --- a/src/stdune/path.mli +++ b/src/stdune/path.mli @@ -1,7 +1,7 @@ (** In the current workspace (anything under the current project root) *) module Local : sig type t - val sexp_of_t : t -> Sexp.t + val to_sexp : t -> Sexp.t val equal : t -> t -> bool val to_string : t -> string end @@ -27,7 +27,7 @@ end type t -val sexp_of_t : t Sexp.To_sexp.t +val to_sexp : t Sexp.To_sexp.t val compare : t -> t -> Ordering.t (** a directory is smaller than its descendants *) @@ -36,7 +36,7 @@ val equal : t -> t -> bool module Set : sig include Set.S with type elt = t - val sexp_of_t : t Sexp.To_sexp.t + val to_sexp : t Sexp.To_sexp.t val of_string_set : String.Set.t -> f:(string -> elt) -> t end diff --git a/src/stdune/set.ml b/src/stdune/set.ml index 3ccf0ad9..44a311ca 100644 --- a/src/stdune/set.ml +++ b/src/stdune/set.ml @@ -46,5 +46,5 @@ module Make(Elt : Comparable.S) : S with type elt = Elt.t = struct let split x t = split t x end -let sexp_of_t to_list f t = +let to_sexp to_list f t = Sexp.To_sexp.list f (to_list t) diff --git a/src/stdune/set.mli b/src/stdune/set.mli index 3a03686f..0ef23de6 100644 --- a/src/stdune/set.mli +++ b/src/stdune/set.mli @@ -2,7 +2,7 @@ module type S = Set_intf.S module Make(Elt : Comparable.S) : S with type elt = Elt.t -val sexp_of_t +val to_sexp : ('a -> 'b list) -> 'b Sexp.To_sexp.t -> 'a Sexp.To_sexp.t diff --git a/src/stdune/univ_map.ml b/src/stdune/univ_map.ml index a2922593..95bdaea0 100644 --- a/src/stdune/univ_map.ml +++ b/src/stdune/univ_map.ml @@ -14,21 +14,21 @@ module Key = struct type 'a Witness.t += T : t Witness.t val id : int val name : string - val sexp_of_t : t -> Sexp.t + val to_sexp : t -> Sexp.t end type 'a t = (module T with type t = 'a) let next = ref 0 - let create (type a) ~name sexp_of_t = + let create (type a) ~name to_sexp = let n = !next in next := n + 1; let module M = struct type t = a type 'a Witness.t += T : t Witness.t let id = n - let sexp_of_t = sexp_of_t + let to_sexp = to_sexp let name = name end in (module M : T with type t = a) @@ -79,7 +79,7 @@ let singleton key v = Int.Map.singleton (Key.id key) (Binding.T (key, v)) let superpose = Int.Map.superpose -let sexp_of_t (t : t) = +let to_sexp (t : t) = let open Sexp in List ( Int.Map.to_list t @@ -87,5 +87,5 @@ let sexp_of_t (t : t) = let (module K) = key in List [ Atom K.name - ; K.sexp_of_t v + ; K.to_sexp v ])) diff --git a/src/stdune/univ_map.mli b/src/stdune/univ_map.mli index 69ebb2ac..d83bd1bf 100644 --- a/src/stdune/univ_map.mli +++ b/src/stdune/univ_map.mli @@ -23,4 +23,4 @@ val singleton : 'a Key.t -> 'a -> t in [b]. *) val superpose : t -> t -> t -val sexp_of_t : t -> Sexp.t +val to_sexp : t -> Sexp.t diff --git a/src/string_with_vars.ml b/src/string_with_vars.ml index 2842a2c0..b7864055 100644 --- a/src/string_with_vars.ml +++ b/src/string_with_vars.ml @@ -101,7 +101,7 @@ let dparse = raw >>| function | Template _ as t -> Exn.code_error "Unexpected dune template from a jbuild file" - [ "t", Dsexp.sexp_of_t (Dsexp.Ast.remove_locs t) + [ "t", Dsexp.to_sexp (Dsexp.Ast.remove_locs t) ] | Atom(loc, A s) -> Jbuild.parse s ~loc ~quoted:false | Quoted_string (loc, s) -> Jbuild.parse s ~loc ~quoted:true @@ -204,7 +204,7 @@ module Var = struct let to_string = string_of_var - let sexp_of_t t = Sexp.To_sexp.string (to_string t) + let to_sexp t = Sexp.To_sexp.string (to_string t) let with_name t ~name = { t with name } @@ -287,7 +287,7 @@ let partial_expand t ~mode ~dir ~f = partial_expand t ~mode ~dir ~f let dgen { template; syntax_version = _ } = Dsexp.Template template -let sexp_of_t t = Dsexp.sexp_of_t (dgen t) +let to_sexp t = Dsexp.to_sexp (dgen t) let is_var { template; syntax_version = _ } ~name = match template.parts with diff --git a/src/string_with_vars.mli b/src/string_with_vars.mli index 19c8aa68..5efce2a1 100644 --- a/src/string_with_vars.mli +++ b/src/string_with_vars.mli @@ -14,7 +14,7 @@ val loc : t -> Loc.t val syntax_version : t -> Syntax.Version.t -val sexp_of_t : t Sexp.To_sexp.t +val to_sexp : t Sexp.To_sexp.t include Dsexp.Sexpable with type t := t @@ -47,7 +47,7 @@ end module Var : sig type t - val sexp_of_t : t -> Sexp.t + val to_sexp : t -> Sexp.t val name : t -> string val loc : t -> Loc.t diff --git a/src/super_context.ml b/src/super_context.ml index 731319c2..8311c97c 100644 --- a/src/super_context.ml +++ b/src/super_context.ml @@ -438,7 +438,7 @@ end = struct | node -> node | exception Exit -> Exn.code_error "Super_context.Env.get called on invalid directory" - [ "dir", Path.sexp_of_t dir ] + [ "dir", Path.to_sexp dir ] let ocaml_flags t ~dir = let rec loop t node = @@ -837,9 +837,9 @@ module Action = struct begin match Dune_file.Bindings.find deps_written_by_user key with | None -> Exn.code_error "Local named variable not present in named deps" - [ "pform", String_with_vars.Var.sexp_of_t pform + [ "pform", String_with_vars.Var.to_sexp pform ; "deps_written_by_user", - Dune_file.Bindings.sexp_of_t Path.sexp_of_t deps_written_by_user + Dune_file.Bindings.to_sexp Path.to_sexp deps_written_by_user ] | Some x -> Value.L.paths x end @@ -862,7 +862,7 @@ module Action = struct end | _ -> Exn.code_error "Unexpected variable in step2" - ["var", String_with_vars.Var.sexp_of_t pform])) + ["var", String_with_vars.Var.to_sexp pform])) let run sctx ~loc ~bindings ~dir ~dep_kind ~targets:targets_written_by_user ~targets_dir ~scope t diff --git a/src/syntax.ml b/src/syntax.ml index 0e1a6959..21b1f43c 100644 --- a/src/syntax.ml +++ b/src/syntax.ml @@ -17,7 +17,7 @@ module Version = struct let to_string (a, b) = sprintf "%u.%u" a b - let sexp_of_t t = Sexp.Atom (to_string t) + let to_sexp t = Sexp.Atom (to_string t) let dgen t = Dsexp.To_sexp.string (to_string t) @@ -43,7 +43,7 @@ end module Supported_versions = struct type t = int Int.Map.t - let sexp_of_t (t : t) = + let to_sexp (t : t) = let open Sexp.To_sexp in (list (pair int int)) (Int.Map.to_list t) @@ -56,7 +56,7 @@ module Supported_versions = struct | Error _ -> Exn.code_error "Syntax.create" - [ "versions", Sexp.To_sexp.list Version.sexp_of_t l ] + [ "versions", Sexp.To_sexp.list Version.to_sexp l ] let greatest_supported_version t = Option.value_exn (Int.Map.max_binding t) @@ -98,7 +98,7 @@ end let create ~name ~desc supported_versions = { name ; desc - ; key = Univ_map.Key.create ~name Version.sexp_of_t + ; key = Univ_map.Key.create ~name Version.to_sexp ; supported_versions = Supported_versions.make supported_versions } @@ -138,8 +138,8 @@ let get_exn t = get_all >>| fun context -> Exn.code_error "Syntax identifier is unset" [ "name", Sexp.To_sexp.string t.name - ; "supported_versions", Supported_versions.sexp_of_t t.supported_versions - ; "context", Univ_map.sexp_of_t context + ; "supported_versions", Supported_versions.to_sexp t.supported_versions + ; "context", Univ_map.to_sexp context ] let desc () = diff --git a/src/syntax.mli b/src/syntax.mli index eb483fe8..94992b9f 100644 --- a/src/syntax.mli +++ b/src/syntax.mli @@ -12,7 +12,7 @@ module Version : sig include Dsexp.Sexpable with type t := t - val sexp_of_t : t Sexp.To_sexp.t + val to_sexp : t Sexp.To_sexp.t val to_string : t -> string diff --git a/src/value.ml b/src/value.ml index 0d3e0fa3..c4f82949 100644 --- a/src/value.ml +++ b/src/value.ml @@ -6,12 +6,12 @@ type t = | Dir of Path.t | Path of Path.t -let sexp_of_t = +let to_sexp = let open Sexp.To_sexp in function | String s -> (pair string string) ("string", s) - | Path p -> (pair string Path.sexp_of_t) ("path", p) - | Dir p -> (pair string Path.sexp_of_t) ("dir", p) + | Path p -> (pair string Path.to_sexp) ("path", p) + | Dir p -> (pair string Path.to_sexp) ("dir", p) let string_of_path ~dir p = Path.reach ~from:dir p diff --git a/src/value.mli b/src/value.mli index 19c641d8..31868c45 100644 --- a/src/value.mli +++ b/src/value.mli @@ -5,7 +5,7 @@ type t = | Dir of Path.t | Path of Path.t -val sexp_of_t : t Sexp.To_sexp.t +val to_sexp : t Sexp.To_sexp.t val to_string : t -> dir:Path.t -> string diff --git a/test/unit-tests/tests.mlt b/test/unit-tests/tests.mlt index 1f35b589..4775b665 100644 --- a/test/unit-tests/tests.mlt +++ b/test/unit-tests/tests.mlt @@ -104,7 +104,7 @@ val conf : Findlib.Config.t = } |}] -let env_pp fmt env = Sexp.pp fmt (Env.sexp_of_t env);; +let env_pp fmt env = Sexp.pp fmt (Env.to_sexp env);; #install_printer env_pp;; [%%expect{|