From 2d5f0e3e8d7ad26e8303339b180e0f1853f0b2f5 Mon Sep 17 00:00:00 2001 From: Christopher Zimmermann Date: Mon, 7 Oct 2019 11:46:34 +0200 Subject: [PATCH] Document behaviour of Fun.finally when finaliser raises --- src/core/CCFun.mli | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/CCFun.mli b/src/core/CCFun.mli index 2bdc77ef..d7d4713f 100644 --- a/src/core/CCFun.mli +++ b/src/core/CCFun.mli @@ -58,16 +58,22 @@ val lexicographic : ('a -> 'a -> int) -> ('a -> 'a -> int) -> 'a -> 'a -> int val finally : h:(unit -> _) -> f:(unit -> 'a) -> 'a (** [finally h f] calls [f ()] and returns its result. If it raises, the same exception is raised; in {b any} case, [h ()] is called after - [f ()] terminates. *) + [f ()] terminates. + If [h ()] raises an exception, then this exception will be passed on and + any exception that may have been raised by [f ()] is lost. *) val finally1 : h:(unit -> _) -> ('a -> 'b) -> 'a -> 'b (** [finally1 ~h f x] is the same as [f x], but after the computation, [h ()] is called whether [f x] rose an exception or not. + If [h ()] raises an exception, then this exception will be passed on and + any exception that may have been raised by [f ()] is lost. @since 0.16 *) val finally2 : h:(unit -> _) -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'c (** [finally2 ~h f x y] is the same as [f x y], but after the computation, [h ()] is called whether [f x y] rose an exception or not. + If [h ()] raises an exception, then this exception will be passed on and + any exception that may have been raised by [f ()] is lost. @since 0.16 *) val opaque_identity : 'a -> 'a