1 We add the option -fno-implicit-prelude here to tell the reader that
2 special names such as () and -> shouldn't be resolved to Prelude.()
3 and Prelude.-> (as they are normally). -- SDM 8/10/97
6 {-# OPTIONS -fno-implicit-prelude #-}
10 -- Everything corresponding to the Report's PreludeList
12 lines, words, unlines, unwords,
15 -- Everything corresponding to the Report's PreludeText
17 Read(readsPrec, readList),
18 Show(showsPrec, showList, show),
19 reads, shows, read, lex,
20 showChar, showString, readParen, showParen,
22 -- Everything corresponding to the Report's PreludeIO
24 ioError, userError, catch,
25 putChar, putStr, putStrLn, print,
26 getChar, getLine, getContents, interact,
27 readFile, writeFile, appendFile, readIO, readLn,
33 Char, String, Int, Integer, Float, Double, IO,
38 -- Includes tuple types + fst, snd, curry, uncurry
39 ()(..), -- The unit type
46 Num((+), (-), (*), negate, abs, signum, fromInteger),
47 -- The fromInt method is exposed only by GlaExts
49 Integral(quot, rem, div, mod, quotRem, divMod, toInteger),
50 -- The toInt method is exposed only by GlaExts
59 mapM, mapM_, sequence, sequence_, (=<<),
62 (&&), (||), not, otherwise,
63 subtract, even, odd, gcd, lcm, (^), (^^),
64 fromIntegral, realToFrac,
65 --exported by PrelTup: fst, snd, curry, uncurry,
66 id, const, (.), flip, ($), until,
67 asTypeOf, error, undefined,
74 #ifndef USE_REPORT_PRELUDE
75 hiding ( takeUInt_append )
88 import PrelErr ( error )
93 ($!) :: (a -> b) -> a -> b
96 -- It is expected that compilers will recognize this and insert error
97 -- messages which are more appropriate to the context in which undefined
101 undefined = error "Prelude.undefined"
105 %*********************************************************
107 \subsection{List sum and product}
109 %*********************************************************
111 List sum and product are defined here because PrelList is too far
112 down the compilation chain to "see" the Num class.
115 -- sum and product compute the sum or product of a finite list of numbers.
116 {-# SPECIALISE sum :: [Int] -> Int #-}
117 {-# SPECIALISE sum :: [Integer] -> Integer #-}
118 {-# SPECIALISE product :: [Int] -> Int #-}
119 {-# SPECIALISE product :: [Integer] -> Integer #-}
120 sum, product :: (Num a) => [a] -> a
121 #ifdef USE_REPORT_PRELUDE
123 product = foldl (*) 1
128 sum' (x:xs) a = sum' xs (a+x)
132 prod (x:xs) a = prod xs (a*x)
137 %*********************************************************
139 \subsection{Coercions}
141 %*********************************************************
144 {-# SPECIALIZE fromIntegral ::
154 Integer -> Double #-}
155 fromIntegral :: (Integral a, Num b) => a -> b
156 fromIntegral = fromInteger . toInteger
158 {-# SPECIALIZE realToFrac ::
163 Rational -> Rational,
168 realToFrac :: (Real a, Fractional b) => a -> b
169 realToFrac = fromRational . toRational