\begin{code}
-{-# OPTIONS_GHC -fno-implicit-prelude #-}
+{-# OPTIONS_GHC -XNoImplicitPrelude #-}
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
-- |
\begin{code}
numericEnumFrom :: (Fractional a) => a -> [a]
-numericEnumFrom = iterate (+1)
+numericEnumFrom n = n `seq` (n : numericEnumFrom (n + 1))
numericEnumFromThen :: (Fractional a) => a -> a -> [a]
-numericEnumFromThen n m = iterate (+(m-n)) n
+numericEnumFromThen n m = n `seq` m `seq` (n : numericEnumFromThen m (m+m-n))
numericEnumFromTo :: (Ord a, Fractional a) => a -> a -> [a]
numericEnumFromTo n m = takeWhile (<= m + 1/2) (numericEnumFrom n)
(^) :: (Num a, Integral b) => a -> b -> a
x0 ^ y0 | y0 < 0 = error "Negative exponent"
| y0 == 0 = 1
- | otherwise = f x0 y0 1
- where -- x0 ^ y0 = (x ^ y) * z
- f x y z | even y = f (x * x) (y `quot` 2) z
+ | otherwise = f x0 y0
+ where -- f : x0 ^ y0 = x ^ y
+ f x y | even y = f (x * x) (y `quot` 2)
+ | y == 1 = x
+ | otherwise = g (x * x) ((y - 1) `quot` 2) x
+ -- g : x0 ^ y0 = (x ^ y) * z
+ g x y z | even y = g (x * x) (y `quot` 2) z
| y == 1 = x * z
- | otherwise = f (x * x) ((y - 1) `quot` 2) (x * z)
+ | otherwise = g (x * x) ((y - 1) `quot` 2) (x * z)
-- | raise a number to an integral power
{-# SPECIALISE (^^) ::