s/sexp_of_t/to_sexp/g

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-08-23 16:02:30 +03:00
parent 2c0ca6e840
commit f3a7725614
47 changed files with 130 additions and 130 deletions

View File

@ -60,8 +60,8 @@ module Repr = struct
| G_evaluated l -> l | G_evaluated l -> l
| G_unevaluated (loc, path, _) -> | G_unevaluated (loc, path, _) ->
Exn.code_error "Build.get_glob_result_exn: got unevaluated" Exn.code_error "Build.get_glob_result_exn: got unevaluated"
[ "loc", Loc.sexp_of_t loc [ "loc", Loc.to_sexp loc
; "path", Path.sexp_of_t path ] ; "path", Path.to_sexp path ]
end end
include Repr include Repr
let repr t = t let repr t = t

View File

@ -188,7 +188,7 @@ let targets =
match loop a [], loop b [] with match loop a [], loop b [] with
| [], [] -> acc | [], [] -> acc
| a, b -> | 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 \ Exn.code_error "Build_interpret.targets: cannot have targets \
under a [if_file_exists]" under a [if_file_exists]"
[ "targets-a", targets a [ "targets-a", targets a
@ -231,7 +231,7 @@ module Rule = struct
match loc with match loc with
| None -> | None ->
Exn.code_error "rule has targets in different directories" 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) (List.map targets ~f:Target.path)
] ]
| Some loc -> | Some loc ->

View File

@ -234,7 +234,7 @@ module Alias0 = struct
if not (Path.is_in_build_dir dir) || String.contains name '/' then if not (Path.is_in_build_dir dir) || String.contains name '/' then
Exn.code_error "Alias0.make: Invalid alias" Exn.code_error "Alias0.make: Invalid alias"
[ "name", Sexp.To_sexp.string name [ "name", Sexp.To_sexp.string name
; "dir", Path.sexp_of_t dir ; "dir", Path.to_sexp dir
]; ];
{ dir; name } { dir; name }
@ -462,7 +462,7 @@ let entry_point t ~f =
| stack -> | stack ->
Exn.code_error Exn.code_error
"Build_system.entry_point: called inside the rule generator callback" "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 () f ()
@ -1536,8 +1536,8 @@ let get_collector t ~dir =
"Build_system.get_collector called on external directory" "Build_system.get_collector called on external directory"
else else
"Build_system.get_collector called on closed directory") "Build_system.get_collector called on closed directory")
[ "dir", Path.sexp_of_t dir [ "dir", Path.to_sexp dir
; "load_dir_stack", Sexp.To_sexp.list Path.sexp_of_t t.load_dir_stack ; "load_dir_stack", Sexp.To_sexp.list Path.to_sexp t.load_dir_stack
] ]
let add_rule t (rule : Build_interpret.Rule.t) = let add_rule t (rule : Build_interpret.Rule.t) =
@ -1558,7 +1558,7 @@ let prefix_rules t prefix ~f =
| [] -> () | [] -> ()
| targets -> | targets ->
Exn.code_error "Build_system.prefix_rules' prefix contains 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; end;
let prefix = let prefix =
match t.prefix with match t.prefix with

View File

@ -11,7 +11,7 @@ module Kind = struct
end end
type t = Default | Opam of Opam.t 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" | Default -> Sexp.To_sexp.string "default"
| Opam o -> | Opam o ->
Sexp.To_sexp.(record [ "root" , string o.root Sexp.To_sexp.(record [ "root" , string o.root
@ -86,12 +86,12 @@ type t =
; which_cache : (string, Path.t option) Hashtbl.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 open Sexp.To_sexp in
let path = Path.sexp_of_t in let path = Path.to_sexp in
record record
[ "name", string t.name [ "name", string t.name
; "kind", Kind.sexp_of_t t.kind ; "kind", Kind.to_sexp t.kind
; "profile", string t.profile ; "profile", string t.profile
; "merlin", bool t.merlin ; "merlin", bool t.merlin
; "for_host", option string (Option.map t.for_host ~f:(fun t -> t.name)) ; "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 ; "ocamlopt", option path t.ocamlopt
; "ocamldep", path t.ocamldep ; "ocamldep", path t.ocamldep
; "ocamlmklib", path t.ocamlmklib ; "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) ; "findlib_path", list path (Findlib.path t.findlib)
; "arch_sixtyfour", bool t.arch_sixtyfour ; "arch_sixtyfour", bool t.arch_sixtyfour
; "natdynlink_supported", ; "natdynlink_supported",
bool (Dynlink_supported.By_the_os.get t.natdynlink_supported) bool (Dynlink_supported.By_the_os.get t.natdynlink_supported)
; "supports_shared_libraries", ; "supports_shared_libraries",
bool (Dynlink_supported.By_the_os.get t.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 ; "opam_vars", Hashtbl.to_sexp string string t.opam_var_cache
; "ocaml_config", Ocaml_config.sexp_of_t t.ocaml_config ; "ocaml_config", Ocaml_config.to_sexp t.ocaml_config
; "which", Hashtbl.sexp_of_t string (option path) t.which_cache ; "which", Hashtbl.to_sexp string (option path) t.which_cache
] ]
let compare a b = compare a.name b.name let compare a b = compare a.name b.name

View File

@ -128,7 +128,7 @@ type t =
; which_cache : (string, Path.t option) Hashtbl.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 *) (** Compare the context names *)
val compare : t -> t -> Ordering.t val compare : t -> t -> Ordering.t

View File

@ -281,8 +281,8 @@ let mlds t (doc : Documentation.t) =
| Some x -> x | Some x -> x
| None -> | None ->
Exn.code_error "Dir_contents.mlds" Exn.code_error "Dir_contents.mlds"
[ "doc", Loc.sexp_of_t doc.loc [ "doc", Loc.to_sexp doc.loc
; "available", Sexp.To_sexp.(list Loc.sexp_of_t) ; "available", Sexp.To_sexp.(list Loc.to_sexp)
(List.map map ~f:(fun (d, _) -> d.Documentation.loc)) (List.map map ~f:(fun (d, _) -> d.Documentation.loc))
] ]

View File

@ -853,9 +853,9 @@ module type Sexpable = sig
val dgen : t To_sexp.t val dgen : t To_sexp.t
end end
let rec sexp_of_t = function let rec to_sexp = function
| Atom (A a) -> Sexp.Atom a | 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 | Quoted_string s -> Sexp.Atom s
| Template t -> | Template t ->
List List

View File

@ -403,7 +403,7 @@ module type Sexpable = sig
val dgen : t To_sexp.t val dgen : t To_sexp.t
end end
val sexp_of_t : t Sexp.To_sexp.t val to_sexp : t Sexp.To_sexp.t
module Io : sig module Io : sig
val load : ?lexer:Lexer.t -> Path.t -> mode:'a Parser.Mode.t -> 'a val load : ?lexer:Lexer.t -> Path.t -> mode:'a Parser.Mode.t -> 'a

View File

@ -363,7 +363,7 @@ module Bindings = struct
Dsexp.List (Dsexp.atom (":" ^ name) :: List.map ~f:dgen bindings)) 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 ( Sexp.List (
List.map bindings ~f:(function List.map bindings ~f:(function
| Unnamed a -> sexp_of_a a | Unnamed a -> sexp_of_a a
@ -439,7 +439,7 @@ module Dep_conf = struct
| Universe -> | Universe ->
Dsexp.unsafe_atom_of_string "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 end
module Preprocess = struct module Preprocess = struct

View File

@ -105,7 +105,7 @@ module Bindings : sig
val dgen : 'a Dsexp.To_sexp.t -> 'a t Dsexp.To_sexp.t 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 end
module Dep_conf : sig module Dep_conf : sig
@ -121,7 +121,7 @@ module Dep_conf : sig
val remove_locs : t -> t val remove_locs : t -> t
include Dsexp.Sexpable with type 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 end
module Buildable : sig module Buildable : sig

View File

@ -7,7 +7,7 @@ module Kind = struct
| Dune | Dune
| Jbuilder | Jbuilder
let sexp_of_t t = let to_sexp t =
Sexp.Atom Sexp.Atom
(match t with (match t with
| Dune -> "dune" | Dune -> "dune"
@ -24,7 +24,7 @@ module Name : sig
val to_string_hum : t -> string val to_string_hum : t -> string
val dparse : t Dsexp.Of_sexp.t 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 encode : t -> string
val decode : string -> t val decode : string -> t
@ -59,11 +59,11 @@ end = struct
| Named s -> s | Named s -> s
| Anonymous p -> sprintf "<anonymous %s>" (Path.to_string_maybe_quoted p) | Anonymous p -> sprintf "<anonymous %s>" (Path.to_string_maybe_quoted p)
let sexp_of_t = function let to_sexp = function
| Named s -> Sexp.To_sexp.string s | Named s -> Sexp.To_sexp.string s
| Anonymous p -> | Anonymous p ->
List [ Atom "anonymous" List [ Atom "anonymous"
; Path.sexp_of_t p ; Path.to_sexp p
] ]
let validate name = let validate name =
@ -132,10 +132,10 @@ module Project_file = struct
; mutable exists : bool ; mutable exists : bool
} }
let sexp_of_t { file; exists } = let to_sexp { file; exists } =
Sexp.To_sexp.( Sexp.To_sexp.(
record record
[ "file", Path.sexp_of_t file [ "file", Path.to_sexp file
; "exists", bool exists ; "exists", bool exists
]) ])
end end
@ -280,11 +280,11 @@ let key =
(fun { name; root; version; project_file; kind (fun { name; root; version; project_file; kind
; stanza_parser = _; packages = _ } -> ; stanza_parser = _; packages = _ } ->
Sexp.To_sexp.record Sexp.To_sexp.record
[ "name", Name.sexp_of_t name [ "name", Name.to_sexp name
; "root", Path.Local.sexp_of_t root ; "root", Path.Local.to_sexp root
; "version", Sexp.To_sexp.(option string) version ; "version", Sexp.To_sexp.(option string) version
; "project_file", Project_file.sexp_of_t project_file ; "project_file", Project_file.to_sexp project_file
; "kind", Kind.sexp_of_t kind ; "kind", Kind.to_sexp kind
]) ])
let set t = Dsexp.Of_sexp.set key t let set t = Dsexp.Of_sexp.set key t

View File

@ -23,7 +23,7 @@ module Name : sig
(** Convert to a string that is suitable for human readable messages *) (** Convert to a string that is suitable for human readable messages *)
val to_string_hum : t -> string 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 *) (** Convert to/from an encoded string that is suitable to use in filenames *)
val encode : t -> string val encode : t -> string

View File

@ -63,7 +63,7 @@ let extend t ~vars =
let extend_env x y = let extend_env x y =
extend x ~vars:y.vars extend x ~vars:y.vars
let sexp_of_t t = let to_sexp t =
let open Sexp.To_sexp in let open Sexp.To_sexp in
(list (pair string string)) (Map.to_list t.vars) (list (pair string string)) (Map.to_list t.vars)

View File

@ -28,6 +28,6 @@ val diff : t -> t -> t
val update : t -> var:string -> f:(string option -> string option) -> 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 val of_string_map : string String.Map.t -> t

View File

@ -103,6 +103,6 @@ let gen ~(dune_version : Syntax.Version.t) confs =
| (x, _) when x >= 1 -> "2" | (x, _) when x >= 1 -> "2"
| (_, _) -> | (_, _) ->
Exn.code_error "Cannot generate dune with unknown version" 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 ; List sexps
] ]

View File

@ -583,20 +583,20 @@ let check_private_deps lib ~loc ~allow_private_deps =
Ok lib Ok lib
let already_in_table (info : Info.t) name x = 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 = let sexp =
match x with match x with
| St_initializing x -> | St_initializing x ->
Sexp.List [Sexp.Atom "Initializing"; Sexp.List [Sexp.Atom "Initializing";
Path.sexp_of_t x.path] Path.to_sexp x.path]
| St_found t -> | St_found t ->
List [Sexp.Atom "Found"; List [Sexp.Atom "Found";
Path.sexp_of_t t.info.src_dir] Path.to_sexp t.info.src_dir]
| St_not_found -> | St_not_found ->
Sexp.Atom "Not_found" Sexp.Atom "Not_found"
| St_hidden (_, { path; reason; _ }) -> | St_hidden (_, { path; reason; _ }) ->
List [Sexp.Atom "Hidden"; List [Sexp.Atom "Hidden";
Path.sexp_of_t path; Sexp.Atom reason] Path.to_sexp path; Sexp.Atom reason]
in in
Exn.code_error Exn.code_error
"Lib_db.DB: resolver returned name that's already in the table" "Lib_db.DB: resolver returned name that's already in the table"

View File

@ -80,7 +80,7 @@ let setup ?(log=Log.no_log)
let contexts = List.concat contexts in let contexts = List.concat contexts in
List.iter contexts ~f:(fun (ctx : Context.t) -> List.iter contexts ~f:(fun (ctx : Context.t) ->
Log.infof log "@[<1>Dune context:@,%a@]@." Sexp.pp 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_done = ref 0 in
let rule_total = ref 0 in let rule_total = ref 0 in
let gen_status_line () = let gen_status_line () =

View File

@ -12,7 +12,7 @@ module Name = struct
let dparse = Dsexp.Of_sexp.string let dparse = Dsexp.Of_sexp.string
let dgen = Dsexp.To_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 = (^) let add_suffix = (^)

View File

@ -8,7 +8,7 @@ module Name : sig
val add_suffix : t -> string -> t 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 compare : t -> t -> Ordering.t
val of_string : string -> t val of_string : string -> t
val to_string : t -> string val to_string : t -> string

View File

@ -17,7 +17,7 @@ module Value = struct
| Words of string list | Words of string list
| Prog_and_args of Prog_and_args.t | 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 let open Sexp.To_sexp in
function function
| Bool x -> bool x | Bool x -> bool x
@ -185,13 +185,13 @@ let to_list t : (string * Value.t) list =
; "supports_shared_libraries", Bool t.supports_shared_libraries ; "supports_shared_libraries", Bool t.supports_shared_libraries
] ]
let sexp_of_t t = let to_sexp t =
let open Sexp in let open Sexp in
List List
(to_list t (to_list t
|> List.map ~f:(fun (k, v) -> |> List.map ~f:(fun (k, v) ->
List [ Atom k List [ Atom k
; Value.sexp_of_t v ; Value.to_sexp v
])) ]))
module Origin = struct module Origin = struct

View File

@ -8,7 +8,7 @@ open! Stdune
contents of [Makefile.config]. *) contents of [Makefile.config]. *)
type t type t
val sexp_of_t : t Sexp.To_sexp.t val to_sexp : t Sexp.To_sexp.t
module Prog_and_args : sig module Prog_and_args : sig
type t = type t =
@ -106,7 +106,7 @@ module Value : sig
val to_string : t -> string val to_string : t -> string
val sexp_of_t : t Sexp.To_sexp.t val to_sexp : t Sexp.To_sexp.t
end end
val to_list : t -> (string * Value.t) list val to_list : t -> (string * Value.t) list

View File

@ -16,10 +16,10 @@ module Dep_graph = struct
| Some x -> x | Some x -> x
| None -> | None ->
Exn.code_error "Ocamldep.Dep_graph.deps_of" Exn.code_error "Ocamldep.Dep_graph.deps_of"
[ "dir", Path.sexp_of_t t.dir [ "dir", Path.to_sexp t.dir
; "modules", Sexp.To_sexp.(list Module.Name.sexp_of_t) ; "modules", Sexp.To_sexp.(list Module.Name.to_sexp)
(Module.Name.Map.keys t.per_module) (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 = let top_closed t modules =

View File

@ -359,8 +359,8 @@ module Unexpanded = struct
| None -> | None ->
Exn.code_error Exn.code_error
"Ordered_set_lang.Unexpanded.expand" "Ordered_set_lang.Unexpanded.expand"
[ "included-file", Path.sexp_of_t path [ "included-file", Path.to_sexp path
; "files", Sexp.To_sexp.(list Path.sexp_of_t) ; "files", Sexp.To_sexp.(list Path.to_sexp)
(Path.Map.keys files_contents) (Path.Map.keys files_contents)
] ]
in in

View File

@ -7,11 +7,11 @@ module File = struct
} }
(* XXX these sexp converters will be useful for the dump command *) (* XXX these sexp converters will be useful for the dump command *)
let _sexp_of_t { src; dst } = let _to_sexp { src; dst } =
Sexp.List Sexp.List
[ Path.sexp_of_t src [ Path.to_sexp src
; Sexp.Atom "as" ; Sexp.Atom "as"
; Path.sexp_of_t dst ; Path.to_sexp dst
] ]
let db : t list ref = ref [] let db : t list ref = ref []

View File

@ -30,7 +30,7 @@ module DB = struct
| None -> | None ->
if Path.is_root d || not (Path.is_managed d) then if Path.is_root d || not (Path.is_managed d) then
Exn.code_error "Scope.DB.find_by_dir got an invalid path" 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 ; "context", Sexp.To_sexp.string t.context
]; ];
let scope = loop (Path.parent_exn d) in let scope = loop (Path.parent_exn d) in
@ -44,10 +44,10 @@ module DB = struct
| Some x -> x | Some x -> x
| None -> | None ->
Exn.code_error "Scope.DB.find_by_name" 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 ; "context", Sexp.To_sexp.string t.context
; "names", ; "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) (Project_name_map.keys t.by_name)
] ]
@ -60,7 +60,7 @@ module DB = struct
| Ok x -> x | Ok x -> x
| Error (_name, project1, project2) -> | Error (_name, project1, project2) ->
let to_sexp (project : Dune_project.t) = 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) (Dune_project.name project, Dune_project.root project)
in in
Exn.code_error "Scope.DB.create got two projects with the same name" Exn.code_error "Scope.DB.create got two projects with the same name"

View File

@ -88,13 +88,13 @@ let iter t ~f = iter ~f t
let keys t = foldi t ~init:[] ~f:(fun key _ acc -> key :: acc) 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 = let module M =
Map.Make(struct Map.Make(struct
type t = key type t = key
let compare a b = Ordering.of_int (compare a b) let compare a b = Ordering.of_int (compare a b)
end) end)
in 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 -> (foldi t ~init:M.empty ~f:(fun key data acc ->
M.add acc key data)) M.add acc key data))

View File

@ -28,4 +28,4 @@ val mem : ('a, _) t -> 'a -> bool
val keys : ('a, _) t -> 'a list 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

View File

@ -7,7 +7,7 @@ module T = struct
Eq Eq
else else
Gt Gt
let sexp_of_t = Sexp.To_sexp.int let to_sexp = Sexp.To_sexp.int
end end
include T include T

View File

@ -1,6 +1,6 @@
type t = int type t = int
val compare : t -> t -> Ordering.t 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 Set : Set.S with type elt = t
module Map : Map.S with type key = t module Map : Map.S with type key = t

View File

@ -30,7 +30,7 @@ let sexp_of_position_no_file (p : Lexing.position) =
; "pos_cnum", int p.pos_cnum ; "pos_cnum", int p.pos_cnum
] ]
let sexp_of_t t = let to_sexp t =
let open Sexp.To_sexp in let open Sexp.To_sexp in
record (* TODO handle when pos_fname differs *) record (* TODO handle when pos_fname differs *)
[ "pos_fname", string t.start.pos_fname [ "pos_fname", string t.start.pos_fname

View File

@ -9,7 +9,7 @@ val none : t
val of_lexbuf : Lexing.lexbuf -> 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 val sexp_of_position_no_file : Lexing.position -> Sexp.t

View File

@ -144,5 +144,5 @@ module Make(Key : Comparable.S) : S with type key = Key.t = struct
union a b ~f:(fun _ _ y -> Some y) union a b ~f:(fun _ _ y -> Some y)
end 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) Sexp.To_sexp.(list (pair f g)) (to_list t)

View File

@ -2,7 +2,7 @@ module type S = Map_intf.S
module Make(Key : Comparable.S) : S with type key = Key.t module Make(Key : Comparable.S) : S with type key = Key.t
val sexp_of_t val to_sexp
: ('a -> ('b * 'c) list) : ('a -> ('b * 'c) list)
-> 'b Sexp.To_sexp.t -> 'b Sexp.To_sexp.t
-> 'c Sexp.To_sexp.t -> 'c Sexp.To_sexp.t

View File

@ -34,7 +34,7 @@ let explode_path =
module External : sig module External : sig
type t 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 : t -> t -> Ordering.t
val compare_val : t -> t -> Ordering.t val compare_val : t -> t -> Ordering.t
@ -71,7 +71,7 @@ end = struct
[ "t", Sexp.To_sexp.string t ]; [ "t", Sexp.To_sexp.string t ];
make 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 = let rec cd_dot_dot t =
@ -125,7 +125,7 @@ end
module Local : sig module Local : sig
type t type t
val sexp_of_t : t Sexp.To_sexp.t val to_sexp : t Sexp.To_sexp.t
val root : t val root : t
val is_root : t -> bool val is_root : t -> bool
@ -213,12 +213,12 @@ end = struct
| exception Not_found -> t | exception Not_found -> t
| i -> String.sub t ~pos:(i + 1) ~len:(len - i - 1) | 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 = let relative ?error_loc t path =
if not (Filename.is_relative path) then ( if not (Filename.is_relative path) then (
Exn.code_error "Local.relative: received absolute path" Exn.code_error "Local.relative: received absolute path"
[ "t", sexp_of_t t [ "t", to_sexp t
; "path", Sexp.To_sexp.string path ; "path", Sexp.To_sexp.string path
] ]
); );
@ -367,7 +367,7 @@ end = struct
let make p = let make p =
if is_root p then if is_root p then
Exn.code_error "Path.Local.Prefix.make" Exn.code_error "Path.Local.Prefix.make"
[ "path", sexp_of_t p ]; [ "path", to_sexp p ];
let p = to_string p in let p = to_string p in
{ len = String.length p { len = String.length p
; path = p ; path = p
@ -398,8 +398,8 @@ let (abs_root, set_root) =
| None -> root_dir := Some new_root | None -> root_dir := Some new_root
| Some root_dir -> | Some root_dir ->
Exn.code_error "set_root: cannot set root_dir more than once" Exn.code_error "set_root: cannot set root_dir more than once"
[ "root_dir", External.sexp_of_t root_dir [ "root_dir", External.to_sexp root_dir
; "new_root_dir", External.sexp_of_t new_root ; "new_root_dir", External.to_sexp new_root
] ]
in in
let abs_root = lazy ( let abs_root = lazy (
@ -427,7 +427,7 @@ module Kind = struct
| Local t -> Local.to_string t | Local t -> Local.to_string t
| External t -> External.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 = let of_string s =
if Filename.is_relative s then if Filename.is_relative s then
@ -478,8 +478,8 @@ let (build_dir_kind, build_dir_prefix, set_build_dir) =
| External _ -> Local.Prefix.invalid) | External _ -> Local.Prefix.invalid)
| Some build_dir -> | Some build_dir ->
Exn.code_error "set_build_dir: cannot set build_dir more than once" Exn.code_error "set_build_dir: cannot set build_dir more than once"
[ "build_dir", Kind.sexp_of_t build_dir [ "build_dir", Kind.to_sexp build_dir
; "new_build_dir", Kind.sexp_of_t new_build_dir ] ; "new_build_dir", Kind.to_sexp new_build_dir ]
in in
let build_dir = lazy ( let build_dir = lazy (
match !build_dir with match !build_dir with
@ -598,12 +598,12 @@ let of_string ?error_loc s =
else else
make_local_path (Local.of_string s ?error_loc) 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 let constr f x y = Sexp.To_sexp.(pair string f) (x, y) in
match t with match t with
| In_build_dir s -> constr Local.sexp_of_t "In_build_dir" s | In_build_dir s -> constr Local.to_sexp "In_build_dir" s
| In_source_tree s -> constr Local.sexp_of_t "In_source_tree" s | In_source_tree s -> constr Local.to_sexp "In_source_tree" s
| External s -> constr External.sexp_of_t "External" s | External s -> constr External.to_sexp "External" s
let of_filename_relative_to_initial_cwd fn = let of_filename_relative_to_initial_cwd fn =
external_ ( external_ (
@ -669,8 +669,8 @@ let append a b =
| In_build_dir _ | External _ -> | In_build_dir _ | External _ ->
Exn.code_error "Path.append called with directory that's \ Exn.code_error "Path.append called with directory that's \
not in the source tree" not in the source tree"
[ "a", sexp_of_t a [ "a", to_sexp a
; "b", sexp_of_t b ; "b", to_sexp b
] ]
| In_source_tree b -> append_local a b | In_source_tree b -> append_local a b
@ -694,7 +694,7 @@ let parent_exn t =
match parent t with match parent t with
| Some p -> p | Some p -> p
| None -> Exn.code_error "Path.parent:exn t is root" | 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 let is_strict_descendant_of_build_dir = function
| In_build_dir p -> not (Local.is_root p) | In_build_dir p -> not (Local.is_root p)
@ -755,7 +755,7 @@ let drop_build_context t =
let drop_build_context_exn t = let drop_build_context_exn t =
match extract_build_context t with 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 | Some (_, t) -> t
let drop_optional_build_context t = let drop_optional_build_context t =
@ -797,7 +797,7 @@ let explode_exn t =
match explode t with match explode t with
| Some s -> s | Some s -> s
| None -> Exn.code_error "Path.explode_exn" | None -> Exn.code_error "Path.explode_exn"
["path", sexp_of_t t] ["path", to_sexp t]
let exists t = let exists t =
try Sys.file_exists (to_string t) try Sys.file_exists (to_string t)
@ -852,7 +852,7 @@ let insert_after_build_dir_exn =
let error a b = let error a b =
Exn.code_error Exn.code_error
"Path.insert_after_build_dir_exn" "Path.insert_after_build_dir_exn"
[ "path" , sexp_of_t a [ "path" , to_sexp a
; "insert", Sexp.To_sexp.string b ; "insert", Sexp.To_sexp.string b
] ]
in in
@ -874,7 +874,7 @@ let rm_rf =
fun t -> fun t ->
if not (is_managed t) then ( if not (is_managed t) then (
Exn.code_error "Path.rm_rf called on external dir" 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 let fn = to_string t in
match Unix.lstat fn with match Unix.lstat fn with
@ -885,7 +885,7 @@ let mkdir_p = function
| External s -> External.mkdir_p s | External s -> External.mkdir_p s
| In_source_tree s -> | In_source_tree s ->
Exn.code_error "Path.mkdir_p cannot dir in source" 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 -> | In_build_dir k ->
Kind.mkdir_p (Kind.append_local (Lazy.force build_dir_kind) 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 module Set = struct
include Set.Make(T) 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 = let of_string_set ss ~f =
String.Set.to_list ss String.Set.to_list ss
|> List.map ~f |> List.map ~f

View File

@ -1,7 +1,7 @@
(** In the current workspace (anything under the current project root) *) (** In the current workspace (anything under the current project root) *)
module Local : sig module Local : sig
type t type t
val sexp_of_t : t -> Sexp.t val to_sexp : t -> Sexp.t
val equal : t -> t -> bool val equal : t -> t -> bool
val to_string : t -> string val to_string : t -> string
end end
@ -27,7 +27,7 @@ end
type t 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 : t -> t -> Ordering.t
(** a directory is smaller than its descendants *) (** a directory is smaller than its descendants *)
@ -36,7 +36,7 @@ val equal : t -> t -> bool
module Set : sig module Set : sig
include Set.S with type elt = t 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 val of_string_set : String.Set.t -> f:(string -> elt) -> t
end end

View File

@ -46,5 +46,5 @@ module Make(Elt : Comparable.S) : S with type elt = Elt.t = struct
let split x t = split t x let split x t = split t x
end end
let sexp_of_t to_list f t = let to_sexp to_list f t =
Sexp.To_sexp.list f (to_list t) Sexp.To_sexp.list f (to_list t)

View File

@ -2,7 +2,7 @@ module type S = Set_intf.S
module Make(Elt : Comparable.S) : S with type elt = Elt.t module Make(Elt : Comparable.S) : S with type elt = Elt.t
val sexp_of_t val to_sexp
: ('a -> 'b list) : ('a -> 'b list)
-> 'b Sexp.To_sexp.t -> 'b Sexp.To_sexp.t
-> 'a Sexp.To_sexp.t -> 'a Sexp.To_sexp.t

View File

@ -14,21 +14,21 @@ module Key = struct
type 'a Witness.t += T : t Witness.t type 'a Witness.t += T : t Witness.t
val id : int val id : int
val name : string val name : string
val sexp_of_t : t -> Sexp.t val to_sexp : t -> Sexp.t
end end
type 'a t = (module T with type t = 'a) type 'a t = (module T with type t = 'a)
let next = ref 0 let next = ref 0
let create (type a) ~name sexp_of_t = let create (type a) ~name to_sexp =
let n = !next in let n = !next in
next := n + 1; next := n + 1;
let module M = struct let module M = struct
type t = a type t = a
type 'a Witness.t += T : t Witness.t type 'a Witness.t += T : t Witness.t
let id = n let id = n
let sexp_of_t = sexp_of_t let to_sexp = to_sexp
let name = name let name = name
end in end in
(module M : T with type t = a) (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 superpose = Int.Map.superpose
let sexp_of_t (t : t) = let to_sexp (t : t) =
let open Sexp in let open Sexp in
List ( List (
Int.Map.to_list t Int.Map.to_list t
@ -87,5 +87,5 @@ let sexp_of_t (t : t) =
let (module K) = key in let (module K) = key in
List List
[ Atom K.name [ Atom K.name
; K.sexp_of_t v ; K.to_sexp v
])) ]))

View File

@ -23,4 +23,4 @@ val singleton : 'a Key.t -> 'a -> t
in [b]. *) in [b]. *)
val superpose : t -> t -> t val superpose : t -> t -> t
val sexp_of_t : t -> Sexp.t val to_sexp : t -> Sexp.t

View File

@ -101,7 +101,7 @@ let dparse =
raw >>| function raw >>| function
| Template _ as t -> | Template _ as t ->
Exn.code_error "Unexpected dune template from a jbuild file" 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 | Atom(loc, A s) -> Jbuild.parse s ~loc ~quoted:false
| Quoted_string (loc, s) -> Jbuild.parse s ~loc ~quoted:true | Quoted_string (loc, s) -> Jbuild.parse s ~loc ~quoted:true
@ -204,7 +204,7 @@ module Var = struct
let to_string = string_of_var 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 = let with_name t ~name =
{ t with 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 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 = let is_var { template; syntax_version = _ } ~name =
match template.parts with match template.parts with

View File

@ -14,7 +14,7 @@ val loc : t -> Loc.t
val syntax_version : t -> Syntax.Version.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 include Dsexp.Sexpable with type t := t
@ -47,7 +47,7 @@ end
module Var : sig module Var : sig
type t type t
val sexp_of_t : t -> Sexp.t val to_sexp : t -> Sexp.t
val name : t -> string val name : t -> string
val loc : t -> Loc.t val loc : t -> Loc.t

View File

@ -438,7 +438,7 @@ end = struct
| node -> node | node -> node
| exception Exit -> | exception Exit ->
Exn.code_error "Super_context.Env.get called on invalid directory" 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 ocaml_flags t ~dir =
let rec loop t node = let rec loop t node =
@ -837,9 +837,9 @@ module Action = struct
begin match Dune_file.Bindings.find deps_written_by_user key with begin match Dune_file.Bindings.find deps_written_by_user key with
| None -> | None ->
Exn.code_error "Local named variable not present in named deps" 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", ; "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 | Some x -> Value.L.paths x
end end
@ -862,7 +862,7 @@ module Action = struct
end end
| _ -> | _ ->
Exn.code_error "Unexpected variable in step2" 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 let run sctx ~loc ~bindings ~dir ~dep_kind
~targets:targets_written_by_user ~targets_dir ~scope t ~targets:targets_written_by_user ~targets_dir ~scope t

View File

@ -17,7 +17,7 @@ module Version = struct
let to_string (a, b) = sprintf "%u.%u" a b 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) let dgen t = Dsexp.To_sexp.string (to_string t)
@ -43,7 +43,7 @@ end
module Supported_versions = struct module Supported_versions = struct
type t = int Int.Map.t type t = int Int.Map.t
let sexp_of_t (t : t) = let to_sexp (t : t) =
let open Sexp.To_sexp in let open Sexp.To_sexp in
(list (pair int int)) (Int.Map.to_list t) (list (pair int int)) (Int.Map.to_list t)
@ -56,7 +56,7 @@ module Supported_versions = struct
| Error _ -> | Error _ ->
Exn.code_error Exn.code_error
"Syntax.create" "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) let greatest_supported_version t = Option.value_exn (Int.Map.max_binding t)
@ -98,7 +98,7 @@ end
let create ~name ~desc supported_versions = let create ~name ~desc supported_versions =
{ name { name
; desc ; 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 ; supported_versions = Supported_versions.make supported_versions
} }
@ -138,8 +138,8 @@ let get_exn t =
get_all >>| fun context -> get_all >>| fun context ->
Exn.code_error "Syntax identifier is unset" Exn.code_error "Syntax identifier is unset"
[ "name", Sexp.To_sexp.string t.name [ "name", Sexp.To_sexp.string t.name
; "supported_versions", Supported_versions.sexp_of_t t.supported_versions ; "supported_versions", Supported_versions.to_sexp t.supported_versions
; "context", Univ_map.sexp_of_t context ; "context", Univ_map.to_sexp context
] ]
let desc () = let desc () =

View File

@ -12,7 +12,7 @@ module Version : sig
include Dsexp.Sexpable with type 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
val to_string : t -> string val to_string : t -> string

View File

@ -6,12 +6,12 @@ type t =
| Dir of Path.t | Dir of Path.t
| Path of Path.t | Path of Path.t
let sexp_of_t = let to_sexp =
let open Sexp.To_sexp in let open Sexp.To_sexp in
function function
| String s -> (pair string string) ("string", s) | String s -> (pair string string) ("string", s)
| Path p -> (pair string Path.sexp_of_t) ("path", p) | Path p -> (pair string Path.to_sexp) ("path", p)
| Dir p -> (pair string Path.sexp_of_t) ("dir", p) | Dir p -> (pair string Path.to_sexp) ("dir", p)
let string_of_path ~dir p = Path.reach ~from:dir p let string_of_path ~dir p = Path.reach ~from:dir p

View File

@ -5,7 +5,7 @@ type t =
| Dir of Path.t | Dir of Path.t
| Path 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 val to_string : t -> dir:Path.t -> string

View File

@ -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;; #install_printer env_pp;;
[%%expect{| [%%expect{|