From d846451c9a07b4e051173878a5446edea029bf5b Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Tue, 18 Nov 2014 11:02:17 +0100 Subject: Making map_union a standard function of the ML library. --- lib/util.ml | 4 ++++ lib/util.mli | 2 ++ 2 files changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/util.ml b/lib/util.ml index 16b5f4615f..531e4fe7d6 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 fd766a30f9..86720fe471 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. *) -- cgit v1.2.3