summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Num.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-01-15 12:33:40 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-01-23 15:31:20 -0500
commit773e2828fde4d8f640082b6bded9945e7b9584e3 (patch)
tree735cc36bc1ce14820890f8734e68280521a6e2ce /libraries/base/GHC/Num.hs
parent97208613414106e493a586d295ca05393e136ba4 (diff)
downloadhaskell-773e2828fde4d8f640082b6bded9945e7b9584e3.tar.gz
Bignum: add Natural constant folding rules (#15821)
* Implement constant folding rules for Natural (similar to Integer ones) * Add mkCoreUbxSum helper in GHC.Core.Make * Remove naturalTo/FromInt We now only provide `naturalTo/FromWord` as the semantics is clear (truncate/zero-extend). For Int we have to deal with negative numbers (throw an exception? convert to Word beforehand?) so we leave the decision about what to do to the caller. Moreover, now that we have sized types (Int8#, Int16#, ..., Word8#, etc.) there is no reason to bless `Int#` more than `Int8#` or `Word8#` (for example). * Replaced a few `()` with `(# #)`
Diffstat (limited to 'libraries/base/GHC/Num.hs')
-rw-r--r--libraries/base/GHC/Num.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/libraries/base/GHC/Num.hs b/libraries/base/GHC/Num.hs
index df0c66b7bd..3d26d35a0d 100644
--- a/libraries/base/GHC/Num.hs
+++ b/libraries/base/GHC/Num.hs
@@ -138,13 +138,13 @@ instance Num Integer where
--
-- @since 4.8.0.0
instance Num Natural where
- (+) = naturalAdd
- (-) = naturalSubThrow
- (*) = naturalMul
- negate = naturalNegate
+ (+) = naturalAdd
+ (-) = naturalSubThrow
+ (*) = naturalMul
+ negate = naturalNegate
fromInteger = integerToNaturalThrow
- abs = id
- signum = naturalSignum
+ abs = id
+ signum = naturalSignum
{-# DEPRECATED quotRemInteger "Use integerQuotRem# instead" #-}
quotRemInteger :: Integer -> Integer -> (# Integer, Integer #)