git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Relax `ModuloRing` to `ModuloSemiRing`
commit21eea0da5044c4ff633fa008f46c8939e05226bc authorGary Burgess <gary.burgess@gmail.com> dateMon 16 Feb 2015, 00:39 (12 years ago) parent28a820c
5 files changed+18−18
prelude/README.md+6−6 prelude/images/Prelude.png prelude/prelude.purs+9−9 src/Language/PureScript/CodeGen/JS/Optimizer/Inliner.hs+1−1 src/Language/PureScript/Constants.hs+2−2
prelude/README.md+6−6
@@ -64,7 +64,7 @@
6464Ring where every nonzero element has a multiplicative inverse (possibly
6565a 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

Binary file not shown.

prelude/prelude.purs+9−9
@@ -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,6 +217,12 @@ 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
@@ -224,15 +230,9 @@ module Prelude
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+1−1
@@ -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+2−2
@@ -175,8 +175,8 @@ semiringNumber = "semiringNumber"
175175ringNumber :: String
176176ringNumber = "ringNumber"
177177
178−moduloRingNumber :: String
179−moduloRingNumber = "moduloRingNumber"
178+moduloSemiRingNumber :: String
179+moduloSemiRingNumber = "moduloSemiRingNumber"
180180
181181numNumber :: String
182182numNumber = "numNumber"