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 from these modules
17 Ord(..), Ordering(..),
20 Show(..), ShowS, shows, show, showChar, showString, showParen,
21 Eval(..), seq, strict,
22 Bool(..), (&&), (||), not, otherwise,
23 Char, String, Int, Integer, Float, Double, Void,
26 ()(..), -- The unit type
29 id, const, (.), flip, ($), until, asTypeOf, undefined,
35 Functor(..), Monad(..), MonadZero(..), MonadPlus(..),
36 accumulate, sequence, mapM, mapM_, guard, filter, concat, applyM,
39 ReadS, Read(readsPrec, readList),
40 reads, read, lex, readParen,
43 IO, FilePath, IOError,
44 fail, userError, catch,
45 putChar, putStr, putStrLn, print,
46 getChar, getLine, getContents, interact,
47 readFile, writeFile, appendFile, readIO, readLn,
51 (%), numerator, denominator, approxRational,
53 Num((+), (-), (*), negate, abs, signum, fromInteger, fromInt{-glaExt-}),
55 Integral(quot, rem, div, mod, quotRem, divMod, toInteger, toInt{-partain-}),
56 Fractional((/), recip, fromRational),
57 Floating(pi, exp, log, sqrt, (**), logBase, sin, cos, tan,
58 asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh),
59 RealFrac(properFraction, truncate, round, ceiling, floor),
60 RealFloat(floatRadix, floatDigits, floatRange, decodeFloat,
61 encodeFloat, exponent, significand, scaleFloat, isNaN,
62 isInfinite, isDenormalized, isIEEE, isNegativeZero),
63 subtract, even, odd, gcd, lcm, (^), (^^),
64 fromIntegral, fromRealFrac, atan2
77 import PrelErr ( error, seqError )
78 import IO ( IO, FilePath, IOError,
79 fail, userError, catch,
80 putChar, putStr, putStrLn, print,
81 getChar, getLine, getContents, interact,
82 readFile, writeFile, appendFile, readIO, readLn
85 {- Declared elsewhere:
87 PrelNum: infixr 8 ^, ^^, **
89 PrelNum: infixl 7 /, %, `quot`, `rem`, `div`, `mod`
90 PrelBase: infixl 6 +, -
91 PrelBase: infixr 5 :, ++
92 PrelBase: infix 4 ==, /=, <. <=, >=, >
95 PrelBase: infixl >>, >>=
101 -- These can't conveniently be defined in PrelBase because they use numbers,
102 -- or I/O, so here's a convenient place to do them.
104 strict :: Eval a => (a -> b) -> a -> b
105 strict f x = x `seq` f x
108 -- "seq" is defined a bit wierdly (see below)
110 -- The reason for the strange "0# -> parError" case is that
111 -- it fools the compiler into thinking that seq is non-strict in
112 -- its second argument (even if it inlines seq at the call site).
113 -- If it thinks seq is strict in "y", then it often evaluates
114 -- "y" before "x", which is totally wrong.
116 -- Just before converting from Core to STG there's a bit of magic
117 -- that recognises the seq# and eliminates the duff case.
120 seq :: Eval a => a -> b -> b
121 seq x y = case (seq# x) of { 0# -> seqError; _ -> y }
123 -- It is expected that compilers will recognize this and insert error
124 -- messages which are more appropriate to the context in which undefined
128 undefined = error "Prelude.undefined"