summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-04-08 13:46:35 +0200
committerBen Gamari <ben@smart-cactus.org>2021-05-12 14:26:57 -0400
commit7713f2a4a6a0e2a9988b87b5bf7e21559edb9c93 (patch)
tree9fdce12ad45284117bf50908366922fd3ae54fa9
parent69c3d63071893a0a2154fb47ce4c919547e2876c (diff)
downloadhaskell-7713f2a4a6a0e2a9988b87b5bf7e21559edb9c93.tar.gz
Bignum: add BigNat Eq/Ord instances (#19647)
(cherry picked from commit a951e06921f05df1601d9c3a39efcede27f3330c)
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/BigNat.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/libraries/ghc-bignum/src/GHC/Num/BigNat.hs b/libraries/ghc-bignum/src/GHC/Num/BigNat.hs
index 7446e5e27f..9991704988 100644
--- a/libraries/ghc-bignum/src/GHC/Num/BigNat.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/BigNat.hs
@@ -1595,3 +1595,19 @@ bigNatFromWordArray# wa n0
-- /without/ cloning the 'WordArray#' into a newly allocated one)
bigNatFromWordArray :: WordArray# -> Word# -> BigNat
bigNatFromWordArray wa n = BN# (bigNatFromWordArray# wa n)
+
+-------------------------------------------------
+-- Instances
+-------------------------------------------------
+
+instance Eq BigNat where
+ BN# a == BN# b = bigNatEq a b
+ BN# a /= BN# b = bigNatNe a b
+
+instance Ord BigNat where
+ (BN# a) `compare` (BN# b) = bigNatCompare a b
+ BN# a < BN# b = bigNatLt a b
+ BN# a <= BN# b = bigNatLe a b
+ BN# a > BN# b = bigNatGt a b
+ BN# a >= BN# b = bigNatGe a b
+