Skip to content

Commit aae1a07

Browse files
committed
Merge pull request purescript#874 from purescript/modulosemiring
Relax `ModuloRing` to `ModuloSemiring`
2 parents 28a820c + 87ff526 commit aae1a07

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

prelude/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
Ring where every nonzero element has a multiplicative inverse (possibly
6565
a non-commutative field) so that ```a `mod` b = zero```
6666

67-
class (ModuloRing a) <= DivisionRing a where
67+
class (Ring a, ModuloSemiring a) <= DivisionRing a where
6868

6969
#### `Eq`
7070

@@ -77,12 +77,12 @@ a non-commutative field) so that ```a `mod` b = zero```
7777
class Functor f where
7878
(<$>) :: forall a b. (a -> b) -> f a -> f b
7979

80-
#### `ModuloRing`
80+
#### `ModuloSemiring`
8181

82-
Ring with modulo operation and division where
82+
Semiring with modulo operation and division where
8383
```a / b * b + (a `mod` b) = a```
8484

85-
class (Ring a) <= ModuloRing a where
85+
class (Semiring a) <= ModuloSemiring a where
8686
(/) :: a -> a -> a
8787
mod :: a -> a -> a
8888

@@ -192,9 +192,9 @@ Addition and multiplication
192192

193193
instance functorArr :: Functor (Prim.Function r)
194194

195-
#### `moduloRingNumber`
195+
#### `moduloSemiringNumber`
196196

197-
instance moduloRingNumber :: ModuloRing Number
197+
instance moduloSemiringNumber :: ModuloSemiring Number
198198

199199
#### `monadArr`
200200

prelude/images/Prelude.png

2.5 KB
Loading

prelude/prelude.purs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ module Prelude
1414
, Bind, (>>=)
1515
, Monad, return, liftM1, ap
1616
, Semiring, (+), zero, (*), one
17+
, ModuloSemiring, (/), mod
1718
, Ring, (-)
1819
, (%)
1920
, negate
20-
, ModuloRing, (/), mod
2121
, DivisionRing
2222
, Num
2323
, Eq, (==), (/=), refEq, refIneq
@@ -217,22 +217,22 @@ module Prelude
217217
(*) :: a -> a -> a
218218
one :: a
219219

220+
-- | Semiring with modulo operation and division where
221+
-- | ```a / b * b + (a `mod` b) = a```
222+
class (Semiring a) <= ModuloSemiring a where
223+
(/) :: a -> a -> a
224+
mod :: a -> a -> a
225+
220226
-- | Addition, multiplication, and subtraction
221227
class (Semiring a) <= Ring a where
222228
(-) :: a -> a -> a
223229

224230
negate :: forall a. (Ring a) => a -> a
225231
negate a = zero - a
226232

227-
-- | Ring with modulo operation and division where
228-
-- | ```a / b * b + (a `mod` b) = a```
229-
class (Ring a) <= ModuloRing a where
230-
(/) :: a -> a -> a
231-
mod :: a -> a -> a
232-
233233
-- | Ring where every nonzero element has a multiplicative inverse (possibly
234234
-- | a non-commutative field) so that ```a `mod` b = zero```
235-
class (ModuloRing a) <= DivisionRing a
235+
class (Ring a, ModuloSemiring a) <= DivisionRing a
236236

237237
-- | A commutative field
238238
class (DivisionRing a) <= Num a
@@ -293,7 +293,7 @@ module Prelude
293293
instance ringNumber :: Ring Number where
294294
(-) = numSub
295295

296-
instance moduloRingNumber :: ModuloRing Number where
296+
instance moduloSemiringNumber :: ModuloSemiring Number where
297297
(/) = numDiv
298298
mod _ _ = 0
299299

src/Language/PureScript/CodeGen/JS/Optimizer/Inliner.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ inlineCommonOperators = applyAll $
105105
, binary C.semiringNumber (C.*) Multiply
106106
, binary C.ringNumber (C.-) Subtract
107107
, unary C.ringNumber C.negate Negate
108-
, binary C.moduloRingNumber (C./) Divide
108+
, binary C.moduloSemiringNumber (C./) Divide
109109

110110
, binary C.ordNumber (C.<) LessThan
111111
, binary C.ordNumber (C.>) GreaterThan

src/Language/PureScript/Constants.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ semiringNumber = "semiringNumber"
175175
ringNumber :: String
176176
ringNumber = "ringNumber"
177177

178-
moduloRingNumber :: String
179-
moduloRingNumber = "moduloRingNumber"
178+
moduloSemiringNumber :: String
179+
moduloSemiringNumber = "moduloSemiringNumber"
180180

181181
numNumber :: String
182182
numNumber = "numNumber"

0 commit comments

Comments
 (0)