/
monomorphic.ml
83 lines (69 loc) · 2.59 KB
/
monomorphic.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
(* Copyright (c) 2013-2017 Kate <kit.ty.kate@disroot.org>. *)
(* See the LICENSE file at the top-level directory. *)
[@@@ocaml.alert "-deprecated"]
module Make (Ty : sig type t end) : sig
external (=) : Ty.t -> Ty.t -> bool = "%equal"
external (<>) : Ty.t -> Ty.t -> bool = "%notequal"
external (<) : Ty.t -> Ty.t -> bool = "%lessthan"
external (>) : Ty.t -> Ty.t -> bool = "%greaterthan"
external (<=) : Ty.t -> Ty.t -> bool = "%lessequal"
external (>=) : Ty.t -> Ty.t -> bool = "%greaterequal"
external compare : Ty.t -> Ty.t -> int = "%compare"
val min : Ty.t -> Ty.t -> Ty.t
val max : Ty.t -> Ty.t -> Ty.t
end = Stdlib
module None : module type of Make(struct type t = unit end) = Stdlib
module Int : module type of Make(struct type t = int end) = Stdlib
module Bool : module type of Make(struct type t = bool end) = Stdlib
module Float : module type of Make(struct type t = float end) = Stdlib
module String : module type of Make(struct type t = string end) = Stdlib
module Stdlib = struct
module Stdlib = struct
include Int
module List = struct
include List
let mem a ~eq xs = List.exists (eq a) xs
let assoc a ~eq xs = snd (List.find (fun (k,_) -> eq a k) xs)
let assoc_opt a ~eq xs = Option.map snd (List.find_opt (fun (k,_) -> eq a k) xs)
let mem_assoc a ~eq xs = List.exists (fun (k, _) -> eq k a) xs
let rec remove_assoc a ~eq = function
| [] -> []
| ((k, _) as pair) :: xs ->
if eq a k then xs else pair :: remove_assoc a ~eq xs
end
module ListLabels = struct
include ListLabels
let mem a ~eq ~set = List.mem a ~eq set
let assoc a ~eq xs = List.assoc a ~eq xs
let assoc_opt a ~eq xs = List.assoc_opt a ~eq xs
let mem_assoc a ~eq ~map = List.mem_assoc a ~eq map
let remove_assoc a ~eq xs = List.remove_assoc a ~eq xs
end
module StdLabels = struct
include (StdLabels :
module type of StdLabels
with module List := StdLabels.List
)
module List = ListLabels
end
#if OCAML_VERSION < (5, 0, 0)
module Pervasives = struct
include Pervasives
include Int
end
#endif
include (Stdlib :
module type of Stdlib
with module List := Stdlib.List
and module ListLabels := Stdlib.ListLabels
and module StdLabels := Stdlib.StdLabels
#if OCAML_VERSION < (5, 0, 0)
and module Pervasives := Stdlib.Pervasives
#endif
and module Int := Stdlib.Int
)
include Int
module Int = Stdlib.Int
end
include Stdlib
end