Source file Utils.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Pervasives = Stdlib

let bracket' ~(init : unit -> 'a) ~(stop : 'b -> 'r) (f : 'a -> 'b) : 'r =
  let acc = init () in
  try
    let acc' = f acc in
    stop acc'
  with exn ->
    let _acc' = stop acc in
    raise exn

let bracket ~(init : unit -> 's) ~(stop : 's -> 'b) (f : 's -> 's) : 'b =
  let acc = init () in
  try
    let acc' = f acc in
    stop acc'
  with exn ->
    let _acc' = stop acc in
    raise exn


let eq_int : int -> int -> bool = Pervasives.(=)