@@ -14,10 +14,10 @@ module Prelude
14 , Bind, (>>=)
14 , Bind, (>>=)
15 , Monad, return, liftM1, ap
15 , Monad, return, liftM1, ap
16 , Semiring, (+), zero, (*), one
16 , Semiring, (+), zero, (*), one
17+ , ModuloSemiRing, (/), mod
17 , Ring, (-)
18 , Ring, (-)
20− , ModuloRing, (/), mod
21 , DivisionRing
21 , DivisionRing
23 , Eq, (==), (/=), refEq, refIneq
23 , Eq, (==), (/=), refEq, refIneq
@@ -217,6 +217,12 @@ module Prelude
217 (*) :: a -> a -> a
217 (*) :: a -> a -> a
220+ -- | Semiring with modulo operation and division where
221+ -- | ```a / b * b + (a `mod` b) = a```
222+ class (Semiring a) <= ModuloSemiRing a where
220 -- | Addition, multiplication, and subtraction
226 -- | Addition, multiplication, and subtraction
221 class (Semiring a) <= Ring a where
227 class (Semiring a) <= Ring a where
222 (-) :: a -> a -> a
228 (-) :: a -> a -> a
@@ -224,15 +230,9 @@ module Prelude
224 negate :: forall a. (Ring a) => a -> a
230 negate :: forall a. (Ring a) => a -> a
225 negate a = zero - a
231 negate a = zero - a
227− -- | Ring with modulo operation and division where
228− -- | ```a / b * b + (a `mod` b) = a```
229− class (Ring a) <= ModuloRing a where
233 -- | Ring where every nonzero element has a multiplicative inverse (possibly
233 -- | Ring where every nonzero element has a multiplicative inverse (possibly
234 -- | a non-commutative field) so that ```a `mod` b = zero```
234 -- | a non-commutative field) so that ```a `mod` b = zero```
235− class (ModuloRing a) <= DivisionRing a
235+ class (Ring a, ModuloSemiRing a) <= DivisionRing a
237 -- | A commutative field
237 -- | A commutative field
238 class (DivisionRing a) <= Num a
238 class (DivisionRing a) <= Num a
@@ -293,7 +293,7 @@ module Prelude
293 instance ringNumber :: Ring Number where
293 instance ringNumber :: Ring Number where
294 (-) = numSub
294 (-) = numSub
296− instance moduloRingNumber :: ModuloRing Number where
296+ instance moduloSemiRingNumber :: ModuloSemiRing Number where
297 (/) = numDiv
297 (/) = numDiv
298 mod _ _ = 0
298 mod _ _ = 0