From 28af6b3b9e0ca029351af750f319303d6b3ba4ee Mon Sep 17 00:00:00 2001 From: Rhiannon Morris Date: Thu, 3 Dec 2020 16:49:28 +0100 Subject: [PATCH] use Fun.protect in bracket --- bracket.ml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bracket.ml b/bracket.ml index ec86ec9..2a05e82 100644 --- a/bracket.ml +++ b/bracket.ml @@ -1,7 +1,5 @@ let bracket ~make:(lazy x) ~act ~free = - match act x with - | result -> free x; result - | exception e -> free x; raise e + Fun.protect (fun () -> act x) ~finally:(fun () -> free x) let infile ~act name = bracket ~make:(lazy (open_in name)) ~act ~free:close_in_noerr