summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-04-08 13:46:35 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-04-09 03:35:08 -0400
commita951e06921f05df1601d9c3a39efcede27f3330c (patch)
treea4b0d42cf1857e9ca9af950b63957c53f5a4cb93
parentc1d6daab8213561cdb4002b66d69b8c6d38a8dd9 (diff)
downloadhaskell-a951e06921f05df1601d9c3a39efcede27f3330c.tar.gz
Bignum: add BigNat Eq/Ord instances (#19647)
-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 bd3137a116..d838f3fa93 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
+