Add helper functions
* Path.Set.sexp_of_t * Module.iter * List.last
This commit is contained in:
parent
5dd8d028ae
commit
897c1e2e5e
|
@ -78,6 +78,11 @@ module List = struct
|
|||
max acc (String.length (f x)))
|
||||
|
||||
let longest l = longest_map l ~f:(fun x -> x)
|
||||
|
||||
let rec last = function
|
||||
| [] -> None
|
||||
| [x] -> Some x
|
||||
| _::xs -> last xs
|
||||
end
|
||||
|
||||
module Hashtbl = struct
|
||||
|
|
|
@ -54,3 +54,7 @@ let cmti_file t ~dir =
|
|||
match t.intf with
|
||||
| None -> Path.relative dir (t.obj_name ^ ".cmt")
|
||||
| Some _ -> Path.relative dir (t.obj_name ^ ".cmti")
|
||||
|
||||
let iter t ~f =
|
||||
f Ml_kind.Impl t.impl;
|
||||
Option.iter t.intf ~f:(f Ml_kind.Intf)
|
||||
|
|
|
@ -35,3 +35,5 @@ val odoc_file : t -> dir:Path.t -> Path.t
|
|||
|
||||
(** Either the .cmti, or .cmt if the module has no interface *)
|
||||
val cmti_file : t -> dir:Path.t -> Path.t
|
||||
|
||||
val iter : t -> f:(Ml_kind.t -> File.t -> unit) -> unit
|
||||
|
|
|
@ -220,7 +220,10 @@ end
|
|||
type t = string
|
||||
let compare = String.compare
|
||||
|
||||
module Set = String_set
|
||||
module Set = struct
|
||||
include String_set
|
||||
let sexp_of_t t = Sexp.To_sexp.(list string) (String_set.elements t)
|
||||
end
|
||||
module Map = String_map
|
||||
|
||||
module Kind = struct
|
||||
|
|
|
@ -39,7 +39,10 @@ val sexp_of_t : t Sexp.To_sexp.t
|
|||
val compare : t -> t -> int
|
||||
(** a directory is smaller than its descendants *)
|
||||
|
||||
module Set : Set.S with type elt = t
|
||||
module Set : sig
|
||||
include Set.S with type elt = t
|
||||
val sexp_of_t : t Sexp.To_sexp.t
|
||||
end
|
||||
module Map : Map.S with type key = t
|
||||
|
||||
val kind : t -> Kind.t
|
||||
|
|
Loading…
Reference in New Issue