Skip to content

Commit 92f2a36

Browse files
committed
Update docs for Ring (fixes #24)
1 parent 83d44df commit 92f2a36

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

docs/Prelude.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ and subtraction operations.
571571
Instances must satisfy the following law in addition to the `Semiring`
572572
laws:
573573

574-
- Additive inverse: `a + (-a) = (-a) + a = zero`
574+
- Additive inverse: `a - a = (zero - a) + a = zero`
575575

576576
#### `(-)`
577577

@@ -587,6 +587,8 @@ laws:
587587
negate :: forall a. (Ring a) => a -> a
588588
```
589589

590+
`negate x` can be used as a shorthand for `zero - x`.
591+
590592
#### `ModuloSemiring`
591593

592594
``` purescript
@@ -977,4 +979,3 @@ string `show x` be executable PureScript code which evaluates to the same
977979
value as the expression `x`.
978980

979981

980-

src/Prelude.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ infixl 6 -
483483
-- | Instances must satisfy the following law in addition to the `Semiring`
484484
-- | laws:
485485
-- |
486-
-- | - Additive inverse: `a + (-a) = (-a) + a = zero`
486+
-- | - Additive inverse: `a - a = (zero - a) + a = zero`
487487
class (Semiring a) <= Ring a where
488488
sub :: a -> a -> a
489489

@@ -500,6 +500,7 @@ instance ringUnit :: Ring Unit where
500500
(-) :: forall a. (Ring a) => a -> a -> a
501501
(-) = sub
502502

503+
-- | `negate x` can be used as a shorthand for `zero - x`.
503504
negate :: forall a. (Ring a) => a -> a
504505
negate a = zero - a
505506

0 commit comments

Comments
 (0)