1 % ------------------------------------------------------------------------------
2 % $Id: Prelude.lhs,v 1.26 2001/05/18 16:54:05 simonmar Exp $
4 % (c) The University of Glasgow, 1992-2000
7 \section[Prelude]{Module @Prelude@}
9 We add the option -fno-implicit-prelude here to tell the reader that
10 special names such as () and -> shouldn't be resolved to Prelude.()
11 and Prelude.-> (as they are normally). -- SDM 8/10/97
14 {-# OPTIONS -fno-implicit-prelude #-}
18 -- Everything corresponding to the Report's PreludeList
20 lines, words, unlines, unwords,
23 -- Everything corresponding to the Report's PreludeText
25 Read(readsPrec, readList),
26 Show(showsPrec, showList, show),
27 reads, shows, read, lex,
28 showChar, showString, readParen, showParen,
30 -- Everything corresponding to the Report's PreludeIO
31 ioError, userError, catch,
34 putStr, putStrLn, print,
36 getLine, getContents, interact,
37 readFile, writeFile, appendFile, readIO, readLn,
43 Char, String, Int, Integer, Float, Double, IO,
48 -- Includes tuple types + fst, snd, curry, uncurry
49 ()(..), -- The unit type
64 -- Monad stuff, from PrelBase, and defined here
67 mapM, mapM_, sequence, sequence_, (=<<),
70 (&&), (||), not, otherwise,
71 subtract, even, odd, gcd, lcm, (^), (^^),
72 fromIntegral, realToFrac,
73 --exported by PrelTup: fst, snd, curry, uncurry,
74 id, const, (.), flip, ($), until,
75 asTypeOf, error, undefined,
84 #ifndef USE_REPORT_PRELUDE
85 hiding ( takeUInt_append )
99 import PrelErr ( error, undefined )
105 %*********************************************************
107 \subsection{Miscellaneous functions}
109 %*********************************************************
112 ($!) :: (a -> b) -> a -> b
117 %*********************************************************
119 \subsection{List sum and product}
121 %*********************************************************
123 List sum and product are defined here because PrelList is too far
124 down the compilation chain to "see" the Num class.
127 -- sum and product compute the sum or product of a finite list of numbers.
128 {-# SPECIALISE sum :: [Int] -> Int #-}
129 {-# SPECIALISE sum :: [Integer] -> Integer #-}
130 {-# SPECIALISE product :: [Int] -> Int #-}
131 {-# SPECIALISE product :: [Integer] -> Integer #-}
132 sum, product :: (Num a) => [a] -> a
133 #ifdef USE_REPORT_PRELUDE
135 product = foldl (*) 1
140 sum' (x:xs) a = sum' xs (a+x)
144 prod (x:xs) a = prod xs (a*x)