use Fun.protect in bracket

This commit is contained in:
Rhiannon Morris 2020-12-03 16:49:28 +01:00
parent 3c2e61176a
commit 28af6b3b9e

View file

@ -1,7 +1,5 @@
let bracket ~make:(lazy x) ~act ~free = let bracket ~make:(lazy x) ~act ~free =
match act x with Fun.protect (fun () -> act x) ~finally:(fun () -> free x)
| result -> free x; result
| exception e -> free x; raise e
let infile ~act name = let infile ~act name =
bracket ~make:(lazy (open_in name)) ~act ~free:close_in_noerr bracket ~make:(lazy (open_in name)) ~act ~free:close_in_noerr