Document behaviour of Fun.finally when finaliser raises

This commit is contained in:
Christopher Zimmermann 2019-10-07 11:46:34 +02:00
parent beb38da150
commit 2d5f0e3e8d

View file

@ -58,16 +58,22 @@ val lexicographic : ('a -> 'a -> int) -> ('a -> 'a -> int) -> 'a -> 'a -> int
val finally : h:(unit -> _) -> f:(unit -> 'a) -> 'a val finally : h:(unit -> _) -> f:(unit -> 'a) -> 'a
(** [finally h f] calls [f ()] and returns its result. If it raises, the (** [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 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 val finally1 : h:(unit -> _) -> ('a -> 'b) -> 'a -> 'b
(** [finally1 ~h f x] is the same as [f x], but after the computation, (** [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. [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 *) @since 0.16 *)
val finally2 : h:(unit -> _) -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'c 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, (** [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. [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 *) @since 0.16 *)
val opaque_identity : 'a -> 'a val opaque_identity : 'a -> 'a