summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaël Deest <gael.deest@tweag.io>2021-03-18 09:40:39 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-20 07:48:01 -0400
commit7d027433d30bdccf787197b28abfdcc1de263b89 (patch)
treed5bd8b55a9c8b1add1aa5e026a0253597d61a175
parentd03d876185da2db9b397c58a383c0eac1892cafc (diff)
downloadhaskell-7d027433d30bdccf787197b28abfdcc1de263b89.tar.gz
[skip ci] Fix 'Ord' documentation inconsistency
Current documentation for the `Ord` typeclass is inconsistent. It simultaneously mentions that: > The 'Ord' class is used for totally ordered datatypes. And: > The Haskell Report defines no laws for 'Ord'. However, '<=' is > customarily expected to implement a non-strict partial order […] The Haskell report (both 98 and 2010 versions) mentions total ordering, which implicitly does define laws. Moreover, `compare :: Ord a => a -> a -> Ordering` and `data Ordering = LT | EQ | GT` imply that the order is indeed total (there is no way to say that two elements are not comparable). This MR fixes the Haddock comment, and adds a comparability law to the list of suggested properties.
-rw-r--r--libraries/ghc-prim/GHC/Classes.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/libraries/ghc-prim/GHC/Classes.hs b/libraries/ghc-prim/GHC/Classes.hs
index 70749097dd..83ba27a767 100644
--- a/libraries/ghc-prim/GHC/Classes.hs
+++ b/libraries/ghc-prim/GHC/Classes.hs
@@ -307,15 +307,15 @@ instance Ord TyCon where
-- 'Ordering' datatype allows a single comparison to determine the precise
-- ordering of two objects.
--
--- The Haskell Report defines no laws for 'Ord'. However, '<=' is customarily
--- expected to implement a non-strict partial order and have the following
--- properties:
+-- 'Ord', as defined by the Haskell report, implements a total order and has the
+-- following properties:
--
+-- [__Comparability__]: @x <= y || y <= x@ = 'True'
-- [__Transitivity__]: if @x <= y && y <= z@ = 'True', then @x <= z@ = 'True'
-- [__Reflexivity__]: @x <= x@ = 'True'
-- [__Antisymmetry__]: if @x <= y && y <= x@ = 'True', then @x == y@ = 'True'
--
--- Note that the following operator interactions are expected to hold:
+-- The following operator interactions are expected to hold:
--
-- 1. @x >= y@ = @y <= x@
-- 2. @x < y@ = @x <= y && x /= y@