summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Enum.hs
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2019-01-08 10:41:50 -0800
committerBen Gamari <ben@smart-cactus.org>2019-01-16 14:17:11 -0500
commitf7def747cf0da103237cd17af5c8bfdbdf5823b2 (patch)
treeea30ac28f46abdcbeeea441373ac3e3443fbac80 /libraries/base/GHC/Enum.hs
parent6e320c279ddfde1e16da204590c1c66a511d9b52 (diff)
downloadhaskell-f7def747cf0da103237cd17af5c8bfdbdf5823b2.tar.gz
Remove from `base` obsolete CPP for `integer-gmp`
* `GHC.Natural` now exports the same functions (regardless of integer backend) * remove unnecessary CPP around instances * remove the 'OPTIMISE_INTEGER_GCD_LCM' flag - almost all of those optimizations now work regardless of which integer backend is used Note that some CPP still remains for situations where there are backend-specific optimization hacks (like a more efficient GMP-only `gcd` for `Int#` and `Word#`).
Diffstat (limited to 'libraries/base/GHC/Enum.hs')
-rw-r--r--libraries/base/GHC/Enum.hs28
1 files changed, 2 insertions, 26 deletions
diff --git a/libraries/base/GHC/Enum.hs b/libraries/base/GHC/Enum.hs
index 18850acd7d..bf85ca0bbb 100644
--- a/libraries/base/GHC/Enum.hs
+++ b/libraries/base/GHC/Enum.hs
@@ -919,7 +919,6 @@ dn_list x0 delta lim = go (x0 :: Integer)
-- Natural
------------------------------------------------------------------------
-#if defined(MIN_VERSION_integer_gmp)
-- | @since 4.8.0.0
instance Enum Natural where
succ n = n `plusNatural` wordToNaturalBase 1##
@@ -927,11 +926,13 @@ instance Enum Natural where
toEnum = intToNatural
+#if defined(MIN_VERSION_integer_gmp)
fromEnum (NatS# w)
| i >= 0 = i
| otherwise = errorWithoutStackTrace "fromEnum: out of Int range"
where
i = I# (word2Int# w)
+#endif
fromEnum n = fromEnum (naturalToInteger n)
enumFrom x = enumDeltaNatural x (wordToNaturalBase 1##)
@@ -962,31 +963,6 @@ enumNegDeltaToNatural x0 ndelta lim = go x0
| x >= ndelta = x : go (x-ndelta)
| otherwise = [x]
-#else
-
--- | @since 4.8.0.0
-instance Enum Natural where
- pred (Natural 0) = errorWithoutStackTrace "Natural.pred: 0"
- pred (Natural n) = Natural (pred n)
- {-# INLINE pred #-}
- succ (Natural n) = Natural (succ n)
- {-# INLINE succ #-}
- fromEnum (Natural n) = fromEnum n
- {-# INLINE fromEnum #-}
- toEnum n | n < 0 = errorWithoutStackTrace "Natural.toEnum: negative"
- | otherwise = Natural (toEnum n)
- {-# INLINE toEnum #-}
-
- enumFrom = coerce (enumFrom :: Integer -> [Integer])
- enumFromThen x y
- | x <= y = coerce (enumFromThen :: Integer -> Integer -> [Integer]) x y
- | otherwise = enumFromThenTo x y (wordToNaturalBase 0##)
-
- enumFromTo = coerce (enumFromTo :: Integer -> Integer -> [Integer])
- enumFromThenTo
- = coerce (enumFromThenTo :: Integer -> Integer -> Integer -> [Integer])
-
-#endif
-- Instances from GHC.Types