mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 19:55:31 -05:00
Make CCPersistentHashtbl.S.merge more general.
This patch brings the merge function of CCPersistentHashtbl
in line with the merge functions of other maps
(Map, BatMap from batteries). In particular, its signature
changes from the restrictive
merge: (key -> 'a option -> 'a option -> 'a option) ->
'a t -> 'a t -> 'a t
to a more general
merge: (key -> 'a option -> 'b option -> 'c option) ->
'a t -> 'b t -> 'c t
This commit is contained in:
parent
d6487a02a0
commit
fecbd7683a
2 changed files with 5 additions and 5 deletions
|
|
@ -89,8 +89,8 @@ module type S = sig
|
|||
(** Fresh copy of the table; the underlying structure is not shared
|
||||
anymore, so using both tables alternatively will be efficient *)
|
||||
|
||||
val merge : (key -> 'a option -> 'a option -> 'a option) ->
|
||||
'a t -> 'a t -> 'a t
|
||||
val merge : (key -> 'a option -> 'b option -> 'c option) ->
|
||||
'a t -> 'b t -> 'c t
|
||||
(** Merge two tables together into a new table. The function's argument
|
||||
correspond to values associated with the key (if present); if the
|
||||
function returns [None] the key will not appear in the result. *)
|
||||
|
|
@ -576,7 +576,7 @@ module Make(H : HashedType) : S with type key = H.t = struct
|
|||
if mem t1 k then tbl
|
||||
else match f k None (Some v2) with
|
||||
| None -> tbl
|
||||
| Some _ -> replace tbl k v2
|
||||
| Some v' -> replace tbl k v'
|
||||
) tbl t2
|
||||
|
||||
(*$R
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ module type S = sig
|
|||
(** Fresh copy of the table; the underlying structure is not shared
|
||||
anymore, so using both tables alternatively will be efficient *)
|
||||
|
||||
val merge : (key -> 'a option -> 'a option -> 'a option) ->
|
||||
'a t -> 'a t -> 'a t
|
||||
val merge : (key -> 'a option -> 'b option -> 'c option) ->
|
||||
'a t -> 'b t -> 'c t
|
||||
(** Merge two tables together into a new table. The function's argument
|
||||
correspond to values associated with the key (if present); if the
|
||||
function returns [None] the key will not appear in the result. *)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue