package mel-bastet

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

Source file Float.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
open Interface

(** Note: `float` is not a fully law abiding member of Additive.Semigroup,
    Multiplicative.Semigroup, Semiring, Division_Ring, and Euclidean_Ring, and any
    abstractions dependent on these, due to potential arithmetic overflows and
    floating point precision issues *)

let approximately_equal =
  (fun ~tolerance a b -> abs_float (a -. b) <= tolerance
    : tolerance:float -> float -> float -> bool)

module Additive = struct
  module Magma : MAGMA with type t = float = struct
    type t = float

    let append = ( +. )
  end

  module Medial_Magma : MEDIAL_MAGMA with type t = float = Magma

  module Semigroup : SEMIGROUP with type t = float = struct
    include Magma
  end

  module Monoid : MONOID with type t = float = struct
    include Semigroup

    let empty = 0.0
  end

  module Quasigroup : QUASIGROUP with type t = float = struct
    include Magma
  end

  module Medial_Quasigroup : MEDIAL_QUASIGROUP with type t = float = struct
    include Medial_Magma
  end

  module Loop : LOOP with type t = float = struct
    include Quasigroup

    let empty = 0.0
  end

  module Group : GROUP with type t = float = struct
    include Monoid

    let inverse = ( *. ) (-1.0)
  end

  module Abelian_Group : ABELIAN_GROUP with type t = float = struct
    include Group
  end
end

module Multiplicative = struct
  module Magma : MAGMA with type t = float = struct
    type t = float

    let append = ( *. )
  end

  module Medial_Magma : MEDIAL_MAGMA with type t = float = Magma

  module Semigroup : SEMIGROUP with type t = float = struct
    include Magma
  end

  module Monoid : MONOID with type t = float = struct
    include Semigroup

    let empty = 1.0
  end

  module Quasigroup : QUASIGROUP with type t = float = struct
    include Magma
  end

  module Medial_Quasigroup : MEDIAL_QUASIGROUP with type t = float = struct
    include Medial_Magma
  end

  module Loop : LOOP with type t = float = struct
    include Quasigroup

    let empty = 1.0
  end
end

module Subtractive = struct
  module Magma : MAGMA with type t = float = struct
    type t = float

    let append = ( -. )
  end

  module Medial_Magma : MEDIAL_MAGMA with type t = float = Magma

  module Quasigroup : QUASIGROUP with type t = float = struct
    include Magma
  end

  module Medial_Quasigroup : MEDIAL_QUASIGROUP with type t = float = struct
    include Medial_Magma
  end
end

module Divisive = struct
  module Magma : MAGMA with type t = float = struct
    type t = float

    let append = ( /. )
  end

  module Medial_Magma : MEDIAL_MAGMA with type t = float = Magma

  module Quasigroup : QUASIGROUP with type t = float = struct
    include Magma
  end

  module Medial_Quasigroup : MEDIAL_QUASIGROUP with type t = float = struct
    include Medial_Magma
  end
end

module Eq : EQ with type t = float = struct
  type t = float

  let eq = ( = )
end

module Ord : ORD with type t = float = struct
  include Eq

  let compare = unsafe_compare
end

module Bounded : BOUNDED with type t = float = struct
  include Ord

  let top = max_float

  and bottom = min_float
end

module Show : SHOW with type t = float = struct
  type t = float

  let show = string_of_float
end

module Semiring : SEMIRING with type t = float = struct
  type t = float

  let add = ( +. )

  let zero = 0.0

  let multiply = ( *. )

  let one = 1.0
end

module Ring : RING with type t = float = struct
  include Semiring

  let subtract = ( -. )
end

module Commutative_Ring : COMMUTATIVE_RING with type t = float = struct
  include Ring
end

module Division_Ring : DIVISION_RING with type t = float = struct
  include Ring

  let reciprocal a = 1.0 /. a
end

module Euclidean_Ring : EUCLIDEAN_RING with type t = float = struct
  include Commutative_Ring

  let degree _ = 1

  let divide = ( /. )

  let modulo _ _ = 0.0
end

module Field : FIELD with type t = float = struct
  include Euclidean_Ring

  include (Division_Ring : DIVISION_RING with type t := t)
end

module Infix = struct
  module Additive = struct
    include Infix.Magma (Additive.Magma)
  end

  module Multiplicative = struct
    include Infix.Magma (Multiplicative.Magma)
  end

  include Infix.Eq (Eq)
  include Infix.Ord (Ord)
  include Infix.Euclidean_Ring (Euclidean_Ring)
end
OCaml

Innovation. Community. Security.