package ocaml-migrate-parsetree

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file ast_408_helper.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 Int = struct
  let to_string = string_of_int
end
module Misc = struct
  module Stdlib = struct
    module String = struct
      include String
      module Map = Map.Make (String)
    end
  end
  let find_in_path = Misc.find_in_path
  let find_in_path_uncap = Misc.find_in_path_uncap
  type ref_and_value = R : 'a ref * 'a -> ref_and_value
  let protect_refs =
    let set_refs l = List.iter (fun (R (r, v)) -> r := v) l in
    fun refs f ->
      let backup = List.map (fun (R (r, _)) -> R (r, !r)) refs in
      set_refs refs;
      match f () with
      | x           -> set_refs backup; x
      | exception e -> set_refs backup; raise e
  let may_map f o = match o with None -> None | Some v -> Some (f v)
end