diff --git a/sledge/lib/import/import.ml b/sledge/lib/import/import.ml index 38a4a194d..5b1b70be2 100644 --- a/sledge/lib/import/import.ml +++ b/sledge/lib/import/import.ml @@ -115,13 +115,7 @@ module Option = Option include Option.Monad_infix include Option.Monad_syntax module List = List - -module Vector = struct - include Vector - - let pp sep pp_elt fs v = List.pp sep pp_elt fs (to_list v) -end - +module Vector = Vector include Vector.Infix module type OrderedType = sig diff --git a/sledge/lib/import/import.mli b/sledge/lib/import/import.mli index 3e70758b4..b57ac0f3e 100644 --- a/sledge/lib/import/import.mli +++ b/sledge/lib/import/import.mli @@ -108,14 +108,7 @@ module Option = Option include module type of Option.Monad_infix include module type of Option.Monad_syntax with type 'a t = 'a option module List = List - -module Vector : sig - include module type of Vector - - val pp : (unit, unit) fmt -> 'a pp -> 'a t pp - (** Pretty-print a vector. *) -end - +module Vector = Vector include module type of Vector.Infix module type OrderedType = sig diff --git a/sledge/lib/import/vector.ml b/sledge/lib/import/vector.ml index 706e4715b..272be639d 100644 --- a/sledge/lib/import/vector.ml +++ b/sledge/lib/import/vector.ml @@ -7,7 +7,7 @@ (** Vector - Immutable view of an array *) -open Base +open (Base : module type of Base with module List := Base.List) (** = 'a array but covariant since imperative operations hidden *) type +'a t @@ -26,6 +26,9 @@ module Infix = struct type +'a vector = 'a t [@@deriving compare, equal, hash, sexp] end +let to_list x = Array.to_list (a x) +let to_array = a +let pp sep pp_elt fs v = List.pp sep pp_elt fs (to_list v) let concat_map x ~f = v (Array.concat_map (a x) ~f:(fun y -> a (f y))) let map_adjacent ~f dummy xs_v = @@ -123,6 +126,3 @@ let reduce_exn x ~f = Array.reduce_exn (a x) ~f let unzip x = let y, z = Array.unzip (a x) in (v y, v z) - -let to_list x = Array.to_list (a x) -let to_array = a diff --git a/sledge/lib/import/vector.mli b/sledge/lib/import/vector.mli index a97a725af..79bc51a94 100644 --- a/sledge/lib/import/vector.mli +++ b/sledge/lib/import/vector.mli @@ -12,6 +12,7 @@ it inconvenient to mutate. *) open Base +open Import0 type +'a t [@@deriving compare, equal, hash, sexp] @@ -19,6 +20,8 @@ module Infix : sig type +'a vector = 'a t [@@deriving compare, equal, hash, sexp] end +val pp : (unit, unit) fmt -> 'a pp -> 'a t pp + (* val binary_search : * ('a t, 'a, 'key) Base__Binary_searchable_intf.binary_search *)