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
module type Comparable = sig
type t
val compare : t -> t -> int
val equal : t -> t -> bool
end
module Ordered = struct
module type S = sig
include Comparable
module Infix : sig
val (=) : t -> t -> bool
val (>) : t -> t -> bool
val (>=) : t -> t -> bool
val (<) : t -> t -> bool
val (<=) : t -> t -> bool
val (<>) : t -> t -> bool
end
end
module Make (C : Comparable) = struct
include C
let equal a b = (C.compare a b) = 0
module Infix = struct
let (=) = equal
let (>) a b = (C.compare a b) > 0
let (>=) a b = (C.compare a b) >= 0
let (<) a b = (C.compare a b) < 0
let (<=) a b = (C.compare a b) <= 0
let (<>) a b = (C.compare a b) <> 0
end
end
end