forked from ocaml/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparameter.ml
68 lines (52 loc) · 2.14 KB
/
parameter.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Pierre Chambart, OCamlPro *)
(* Mark Shinwell and Leo White, Jane Street Europe *)
(* *)
(* Copyright 2013--2016 OCamlPro SAS *)
(* Copyright 2014--2016 Jane Street Group LLC *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Lesser General Public License version 2.1, with the *)
(* special exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)
[@@@ocaml.warning "+a-4-9-30-40-41-42"]
[@@@ocaml.warning "+9"]
(* Warning 9 is enabled to ensure correct update of each function when
a field is added to type parameter *)
type parameter = {
var : Variable.t;
}
let wrap var = { var }
let var p = p.var
module M =
Identifiable.Make (struct
type t = parameter
let compare { var = var1 } { var = var2 } =
Variable.compare var1 var2
let equal { var = var1 } { var = var2 } =
Variable.equal var1 var2
let hash { var } =
Variable.hash var
let print ppf { var } =
Variable.print ppf var
let output o { var } =
Variable.output o var
end)
module T = M.T
include T
module Map = M.Map
module Tbl = M.Tbl
module Set = struct
include M.Set
let vars l = Variable.Set.of_list (List.map var l)
end
let rename ?current_compilation_unit p =
{ var = Variable.rename ?current_compilation_unit p.var }
let map_var f { var } = { var = f var }
module List = struct
let vars params = List.map (fun { var } -> var) params
end