X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fstd%2FPrelude.lhs;h=79feaf889c26bc90a47ccc58aae428a291eced34;hb=7dee9e10796acdc3af04f222ef06808ad3d1b611;hp=71a0378f2fb4bb18b44b66e501af25c928de9032;hpb=c415cd35368f45739132fc180837fc07f0490921;p=ghc-hetmet.git diff --git a/ghc/lib/std/Prelude.lhs b/ghc/lib/std/Prelude.lhs index 71a0378..79feaf8 100644 --- a/ghc/lib/std/Prelude.lhs +++ b/ghc/lib/std/Prelude.lhs @@ -1,3 +1,11 @@ +% ------------------------------------------------------------------------------ +% $Id: Prelude.lhs,v 1.27 2001/11/14 11:15:53 simonmar Exp $ +% +% (c) The University of Glasgow, 1992-2000 +% + +\section[Prelude]{Module @Prelude@} + We add the option -fno-implicit-prelude here to tell the reader that special names such as () and -> shouldn't be resolved to Prelude.() and Prelude.-> (as they are normally). -- SDM 8/10/97 @@ -20,10 +28,12 @@ module Prelude ( showChar, showString, readParen, showParen, -- Everything corresponding to the Report's PreludeIO - FilePath, IOError, ioError, userError, catch, - putChar, putStr, putStrLn, print, - getChar, getLine, getContents, interact, + FilePath, IOError, + putChar, + putStr, putStrLn, print, + getChar, + getLine, getContents, interact, readFile, writeFile, appendFile, readIO, readLn, Bool(..), @@ -43,15 +53,15 @@ module Prelude ( Ord(..), Enum(..), Bounded(..), - Num((+), (-), (*), negate, abs, signum, fromInteger, fromInt{-glaExt-}), + Num(..), Real(..), - Integral(quot, rem, div, mod, quotRem, divMod, toInteger, toInt{-partain-}), + Integral(..), Fractional(..), Floating(..), RealFrac(..), RealFloat(..), - -- From Monad + -- Monad stuff, from PrelBase, and defined here Monad(..), Functor(..), mapM, mapM_, sequence, sequence_, (=<<), @@ -67,42 +77,57 @@ module Prelude ( ) where +import Monad + import PrelBase -import PrelList hiding ( takeUInt_append ) +import PrelList +#ifndef USE_REPORT_PRELUDE + hiding ( takeUInt_append ) +#endif +import PrelIO +import PrelIOBase +import PrelException import PrelRead import PrelEnum import PrelNum -import PrelNumExtra +import PrelReal +import PrelFloat import PrelTup import PrelMaybe import PrelShow -import PrelConc -import Monad -import Maybe -import PrelErr ( error ) -import IO +import PrelErr ( error, undefined ) infixr 0 $! +\end{code} -($!) :: (a -> b) -> a -> b -f $! x = x `seq` f x --- It is expected that compilers will recognize this and insert error --- messages which are more appropriate to the context in which undefined --- appears. +%********************************************************* +%* * +\subsection{Miscellaneous functions} +%* * +%********************************************************* -undefined :: a -undefined = error "Prelude.undefined" +\begin{code} +($!) :: (a -> b) -> a -> b +f $! x = x `seq` f x \end{code} +%********************************************************* +%* * +\subsection{List sum and product} +%* * +%********************************************************* + 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 @@ -118,3 +143,4 @@ product l = prod l 1 prod (x:xs) a = prod xs (a*x) #endif \end{code} +