aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorGravatar Hugo Herbelin <Hugo.Herbelin@inria.fr>2014-11-18 11:02:17 +0100
committerGravatar Hugo Herbelin <Hugo.Herbelin@inria.fr>2014-11-19 18:52:13 +0100
commitd846451c9a07b4e051173878a5446edea029bf5b (patch)
tree0e8920a1174b268b6268d5615ffa5941bae3daa7 /lib
parent36c2559cefb54dc503fea375d15d3224992f6221 (diff)
Making map_union a standard function of the ML library.
Diffstat (limited to 'lib')
-rw-r--r--lib/util.ml4
-rw-r--r--lib/util.mli2
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/util.ml b/lib/util.ml
index 16b5f4615..531e4fe7d 100644
--- a/lib/util.ml
+++ b/lib/util.ml
@@ -124,3 +124,7 @@ let delayed_force f = f ()
type ('a, 'b) union = ('a, 'b) CSig.union = Inl of 'a | Inr of 'b
type 'a until = 'a CSig.until = Stop of 'a | Cont of 'a
+
+let map_union f g = function
+ | Inl a -> Inl (f a)
+ | Inr b -> Inr (g b)
diff --git a/lib/util.mli b/lib/util.mli
index fd766a30f..86720fe47 100644
--- a/lib/util.mli
+++ b/lib/util.mli
@@ -100,6 +100,8 @@ val delayed_force : 'a delayed -> 'a
type ('a, 'b) union = ('a, 'b) CSig.union = Inl of 'a | Inr of 'b
(** Union type *)
+val map_union : ('a -> 'c) -> ('b -> 'd) -> ('a, 'b) union -> ('c, 'd) union
+
type 'a until = 'a CSig.until = Stop of 'a | Cont of 'a
(** Used for browsable-until structures. *)