git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Relax `ModuloRing` to `ModuloSemiRing`
21eea0dGary Burgess
prelude/README.md+6−6
@@ -64,7 +64,7 @@
64Ring where every nonzero element has a multiplicative inverse (possibly
64Ring where every nonzero element has a multiplicative inverse (possibly
65a non-commutative field) so that ```a `mod` b = zero```
65a non-commutative field) so that ```a `mod` b = zero```
66
66
67− class (ModuloRing a) <= DivisionRing a where
67+ class (Ring a, ModuloSemiRing a) <= DivisionRing a where
68
68
69#### `Eq`
69#### `Eq`
70
70
@@ -77,12 +77,12 @@ a non-commutative field) so that ```a `mod` b = zero```
77 class Functor f where
77 class Functor f where
78 (<$>) :: forall a b. (a -> b) -> f a -> f b
78 (<$>) :: forall a b. (a -> b) -> f a -> f b
79
79
80−#### `ModuloRing`
80+#### `ModuloSemiRing`
81
81
82−Ring with modulo operation and division where
82+Semiring with modulo operation and division where
83```a / b * b + (a `mod` b) = a```
83```a / b * b + (a `mod` b) = a```
84
84
85− class (Ring a) <= ModuloRing a where
85+ class (Semiring a) <= ModuloSemiRing a where
86 (/) :: a -> a -> a
86 (/) :: a -> a -> a
87 mod :: a -> a -> a
87 mod :: a -> a -> a
88
88
@@ -192,9 +192,9 @@ Addition and multiplication
192
192
193 instance functorArr :: Functor (Prim.Function r)
193 instance functorArr :: Functor (Prim.Function r)
194
194
195−#### `moduloRingNumber`
195+#### `moduloSemiRingNumber`
196
196
197− instance moduloRingNumber :: ModuloRing Number
197+ instance moduloSemiRingNumber :: ModuloSemiRing Number
198
198
199#### `monadArr`
199#### `monadArr`
200
200
prelude/images/Prelude.png

Binary file not shown.

prelude/prelude.purs+9−9
@@ -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, (-)
18 , (%)
19 , (%)
19 , negate
20 , negate
20− , ModuloRing, (/), mod
21 , DivisionRing
21 , DivisionRing
22 , Num
22 , Num
23 , Eq, (==), (/=), refEq, refIneq
23 , Eq, (==), (/=), refEq, refIneq
@@ -217,6 +217,12 @@ module Prelude
217 (*) :: a -> a -> a
217 (*) :: a -> a -> a
218 one :: a
218 one :: a
219
219
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+
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
226
232
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−
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
236
236
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
295
295
296− instance moduloRingNumber :: ModuloRing Number where
296+ instance moduloSemiRingNumber :: ModuloSemiRing Number where
297 (/) = numDiv
297 (/) = numDiv
298 mod _ _ = 0
298 mod _ _ = 0
299
299
src/Language/PureScript/CodeGen/JS/Optimizer/Inliner.hs+1−1
@@ -105,7 +105,7 @@ inlineCommonOperators = applyAll $
105 , binary C.semiringNumber (C.*) Multiply
105 , binary C.semiringNumber (C.*) Multiply
106 , binary C.ringNumber (C.-) Subtract
106 , binary C.ringNumber (C.-) Subtract
107 , unary C.ringNumber C.negate Negate
107 , unary C.ringNumber C.negate Negate
108− , binary C.moduloRingNumber (C./) Divide
108+ , binary C.moduloSemiRingNumber (C./) Divide
109
109
110 , binary C.ordNumber (C.<) LessThan
110 , binary C.ordNumber (C.<) LessThan
111 , binary C.ordNumber (C.>) GreaterThan
111 , binary C.ordNumber (C.>) GreaterThan
src/Language/PureScript/Constants.hs+2−2
@@ -175,8 +175,8 @@ semiringNumber = "semiringNumber"
175ringNumber :: String
175ringNumber :: String
176ringNumber = "ringNumber"
176ringNumber = "ringNumber"
177
177
178−moduloRingNumber :: String
178+moduloSemiRingNumber :: String
179−moduloRingNumber = "moduloRingNumber"
179+moduloSemiRingNumber = "moduloSemiRingNumber"
180
180
181numNumber :: String
181numNumber :: String
182numNumber = "numNumber"
182numNumber = "numNumber"