module Prelude (
- -- Everything from these modules
- module PrelList,
+ -- Everything corresponding to the Report's PreludeList
+ module PrelList,
+ lines, words, unlines, unwords,
+ sum, product,
-- Everything corresponding to the Report's PreludeText
ReadS, ShowS,
Either(..),
Ordering(..),
Char, String, Int, Integer, Float, Double, IO,
- Ratio, Rational,
+ Rational,
[]((:), []),
module PrelTup,
Ord(..),
Enum(..),
Bounded(..),
- Num((+), (-), (*), negate, abs, signum, fromInteger, fromInt{-glaExt-}),
+ Num((+), (-), (*), negate, abs, signum, fromInteger),
+ -- The fromInt method is exposed only by GlaExts
Real(..),
- Integral(quot, rem, div, mod, quotRem, divMod, toInteger, toInt{-partain-}),
+ Integral(quot, rem, div, mod, quotRem, divMod, toInteger),
+ -- The toInt method is exposed only by GlaExts
Fractional(..),
Floating(..),
RealFrac(..),
) where
import PrelBase
-import PrelList hiding ( takeUInt )
+import PrelList
+#ifndef USE_REPORT_PRELUDE
+ hiding ( takeUInt_append )
+#endif
import PrelRead
+import PrelEnum
import PrelNum
import PrelNumExtra
import PrelTup
import PrelMaybe
-import PrelEither
-import PrelBounded
+import PrelShow
import PrelConc
import Monad
import Maybe
\end{code}
+List sum and product are defined here because PrelList is too far
+down the compilation chain to "see" the Num class.
+\begin{code}
+-- sum and product compute the sum or product of a finite list of numbers.
+{-# SPECIALISE sum :: [Int] -> Int #-}
+{-# SPECIALISE sum :: [Integer] -> Integer #-}
+{-# SPECIALISE product :: [Int] -> Int #-}
+{-# SPECIALISE product :: [Integer] -> Integer #-}
+sum, product :: (Num a) => [a] -> a
+#ifdef USE_REPORT_PRELUDE
+sum = foldl (+) 0
+product = foldl (*) 1
+#else
+sum l = sum' l 0
+ where
+ sum' [] a = a
+ sum' (x:xs) a = sum' xs (a+x)
+product l = prod l 1
+ where
+ prod [] a = a
+ prod (x:xs) a = prod xs (a*x)
+#endif
+\end{code}