Compare commits

...

2 Commits

Author SHA1 Message Date
Rhiannon Morris a2030efaca add label to ambiguous argument 2020-12-06 10:37:01 +01:00
Rhiannon Morris 9326f47ba2 move Set_ext to just Set 2020-12-06 10:15:56 +01:00
8 changed files with 23 additions and 19 deletions

View File

@ -1,4 +1,4 @@
module IntSet = Set_ext.Make(Int)
module IntSet = Set.Make(Int)
let read_ints =
Bracket.infile_lines ~line:int_of_string ~of_seq:IntSet.of_seq

View File

@ -17,7 +17,7 @@ let%test_module _ = (module struct
end)
module StrSet = Set_ext.Make(String)
module StrSet = Set.Make(String)
let optional_fields = StrSet.singleton "cid"

View File

@ -1,4 +1,4 @@
module CharSet = Set_ext.Make(Char)
module CharSet = Set.Make(Char)
let to_set str = String.to_seq str |> CharSet.of_seq

8
seq.ml
View File

@ -50,13 +50,13 @@ let rec drop_while p seq =
| Cons (x, xs) ->
if p x then drop_while p xs else cons x xs
let chunks p =
let chunks ~sep =
unfold (fun seq ->
match break' p seq with
match break' sep seq with
| Empty_seq -> None
| Span (lst, seq) -> Some (lst, drop_while p seq))
| Span (lst, seq) -> Some (lst, drop_while sep seq))
let line_chunks' = chunks (fun s -> s = "")
let line_chunks' = chunks ~sep:(fun s -> s = "")
let line_chunks ?(join=" ") seq = map (String.concat join) (line_chunks' seq)
let%test_module _ = (module struct

View File

@ -11,7 +11,7 @@ val break: ('a -> bool) -> 'a t -> 'a list * 'a t
val drop_while: ('a -> bool) -> 'a t -> 'a t
val chunks: ('a -> bool) -> 'a t -> 'a list t
val chunks: sep:('a -> bool) -> 'a t -> 'a list t
val line_chunks': string t -> string list t
val line_chunks: ?join:string -> string t -> string t

View File

@ -1,10 +1,12 @@
module type OrderedType = Stdlib.Set.OrderedType
module type S = sig
include Set.S
include Stdlib.Set.S
val exists_opt: (elt -> 'a option) -> t -> 'a option
end
module Make(Elt: Set.OrderedType) = struct
include Set.Make(Elt)
module Make(Elt: OrderedType) = struct
include Stdlib.Set.Make(Elt)
let exists_opt (type a) (f: elt -> a option) set =
let exception Found of a in

10
set.mli Normal file
View File

@ -0,0 +1,10 @@
module type OrderedType = Stdlib.Set.OrderedType
module type S = sig
include Stdlib.Set.S
val exists_opt: (elt -> 'a option) -> t -> 'a option
end
module Make(Elt: OrderedType): S
with type elt = Elt.t
and type t = Stdlib.Set.Make(Elt).t

View File

@ -1,8 +0,0 @@
module type S = sig
include Set.S
val exists_opt: (elt -> 'a option) -> t -> 'a option
end
module Make(Elt: Set.OrderedType): S
with type elt = Elt.t
and type t = Set.Make(Elt).t