Skip to content

Commit 178e71d

Browse files
authored
Merge pull request #93 from purescript/doc-updates
Fix typo, document non-law-abiding numeric instances
2 parents 60bf306 + ada7a29 commit 178e71d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Data/Eq.purs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import Data.Void (Void)
1010
-- | - Reflexivity: `x == x = true`
1111
-- | - Symmetry: `x == y = y == x`
1212
-- | - Transitivity: if `x == y` and `y == z` then `x == z`
13+
-- |
14+
-- | **Note:** The `Number` type is not an entirely law abiding member of this
15+
-- | class due to the presence of `NaN`, since `NaN /= NaN`. Additionally,
16+
-- | computing with `Number` can result in a loss of precision, so sometimes
17+
-- | values that should be equivalent are not.
1318
class Eq a where
1419
eq :: a -> a -> Boolean
1520

src/Data/Semiring.purs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ import Data.Unit (Unit, unit)
1717
-- | - Multiplication distributes over addition:
1818
-- | - Left distributivity: `a * (b + c) = (a * b) + (a * c)`
1919
-- | - Right distributivity: `(a + b) * c = (a * c) + (b * c)`
20-
-- | - Annihiliation: `zero * a = a * zero = zero`
20+
-- | - Annihilation: `zero * a = a * zero = zero`
21+
-- |
22+
-- | **Note:** The `Number` and `Int` types are not fully law abiding
23+
-- | members of this class hierarchy due to the potential for arithmetic
24+
-- | overflows, and in the case of `Number`, the presence of `NaN` and
25+
-- | `Infinity` values. The behaviour is unspecified in these cases.
2126
class Semiring a where
2227
add :: a -> a -> a
2328
zero :: a

0 commit comments

Comments
 (0)