From 630b1fea1e41a1e00860a30742b6ab8ade8a0de0 Mon Sep 17 00:00:00 2001
From: Bodigrim <andrew.lelechenko@gmail.com>
Date: Tue, 9 May 2023 21:09:10 +0100
Subject: [PATCH] Document unlawfulness of instance Num Fixed

Fixes #22712
---
 libraries/base/Data/Fixed.hs | 7 +++++++
 libraries/base/GHC/Float.hs  | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libraries/base/Data/Fixed.hs b/libraries/base/Data/Fixed.hs
index bb45d20a383e..a34f73ecd21b 100644
--- a/libraries/base/Data/Fixed.hs
+++ b/libraries/base/Data/Fixed.hs
@@ -163,6 +163,13 @@ instance Enum (Fixed a) where
     enumFromThenTo (MkFixed a) (MkFixed b) (MkFixed c) = fmap MkFixed (enumFromThenTo a b c)
 
 -- | @since 2.01
+--
+-- Multiplication is not associative or distributive:
+--
+-- >>> (0.2 * 0.6 :: Deci) * 0.9 == 0.2 * (0.6 * 0.9)
+-- False
+-- >>> (0.1 + 0.1 :: Deci) * 0.5 == 0.1 * 0.5 + 0.1 * 0.5
+-- False
 instance (HasResolution a) => Num (Fixed a) where
     (MkFixed a) + (MkFixed b) = MkFixed (a + b)
     (MkFixed a) - (MkFixed b) = MkFixed (a - b)
diff --git a/libraries/base/GHC/Float.hs b/libraries/base/GHC/Float.hs
index 195c23b1f4fa..8045216b2519 100644
--- a/libraries/base/GHC/Float.hs
+++ b/libraries/base/GHC/Float.hs
@@ -279,7 +279,7 @@ class  (RealFrac a, Floating a) => RealFloat a  where
 --
 -- This instance implements IEEE 754 standard with all its usual pitfalls
 -- about NaN, infinities and negative zero.
--- Neither addition not multiplication are associative or distributive:
+-- Neither addition nor multiplication are associative or distributive:
 --
 -- >>> (0.1 + 0.1 :: Float) + 0.5 == 0.1 + (0.1 + 0.5)
 -- False
@@ -533,7 +533,7 @@ instance  Show Float  where
 --
 -- This instance implements IEEE 754 standard with all its usual pitfalls
 -- about NaN, infinities and negative zero.
--- Neither addition not multiplication are associative or distributive:
+-- Neither addition nor multiplication are associative or distributive:
 --
 -- >>> (0.1 + 0.1) + 0.4 == 0.1 + (0.1 + 0.4)
 -- False
-- 
GitLab