package bastet

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

Source file Int.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
open Interface

(** Note: `int` is not a fully law abiding member of Additive.Semigroup,
    Multiplicative.Semigroup and Semiring, and any abstractions dependent on these,
    due to potential arithmetic overflows *)

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

    let append = ( + )
  end

  module Medial_Magma : MEDIAL_MAGMA with type t = int = Magma

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

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

    let empty = 0
  end

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

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

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

    let empty = 0
  end

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

    let inverse = ( * ) (-1)
  end

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

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

    let append = ( * )
  end

  module Medial_Magma : MEDIAL_MAGMA with type t = int = Magma

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

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

    let empty = 1
  end

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

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

    let empty = 1
  end
end

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

    let append = ( - )
  end

  module Medial_Magma : MEDIAL_MAGMA with type t = int = Magma

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

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

    let append = ( / )
  end
end

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

  let eq = ( = )
end

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

  let compare = unsafe_compare
end

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

  let top = max_int

  let bottom = min_int
end

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

  let show = string_of_int
end

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

  let add = ( + )

  let zero = 0

  let multiply = ( * )

  let one = 1
end

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

  let subtract = ( - )
end

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

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

  let degree a = min (abs a) Bounded.top

  let divide = ( / )

  let modulo a b = a mod b
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