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
18 Ord(..), Ordering(..),
21 Show(..), ShowS, shows, show, showChar, showString, showParen,
23 Eval(..), seq, strict,
24 Bool(..), (&&), (||), not, otherwise,
25 Char, String, Int, Integer, Float, Double, Void,
28 ()(..), -- The unit type
31 id, const, (.), flip, ($), until, asTypeOf, undefined,
37 Functor(..), Monad(..), MonadZero(..), MonadPlus(..),
38 accumulate, sequence, mapM, mapM_, guard, filter, concat, applyM,
41 ReadS, Read(readsPrec, readList),
42 reads, read, lex, readParen,
48 (%), numerator, denominator, approxRational,
50 Num((+), (-), (*), negate, abs, signum, fromInteger),
52 Integral(quot, rem, div, mod, quotRem, divMod, toInteger, toInt{-partain-}),
53 Fractional((/), recip, fromRational),
54 Floating(pi, exp, log, sqrt, (**), logBase, sin, cos, tan,
55 asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh),
56 RealFrac(properFraction, truncate, round, ceiling, floor),
57 RealFloat(floatRadix, floatDigits, floatRange, decodeFloat,
58 encodeFloat, exponent, significand, scaleFloat, isNaN,
59 isInfinite, isDenormalized, isIEEE, isNegativeZero),
60 subtract, even, odd, gcd, lcm, (^), (^^),
61 fromIntegral, fromRealFrac, atan2
74 import Error ( error )
77 -- These can't conveniently be defined in PrelBase because they use numbers,
78 -- or I/O, so here's a convenient place to do them.
80 strict :: Eval a => (a -> b) -> a -> b
81 strict f x = x `seq` f x
84 -- "seq" is defined a bit wierdly (see below)
86 -- The reason for the strange "0# -> parError" case is that
87 -- it fools the compiler into thinking that seq is non-strict in
88 -- its second argument (even if it inlines seq at the call site).
89 -- If it thinks seq is strict in "y", then it often evaluates
90 -- "y" before "x", which is totally wrong.
92 -- Just before converting from Core to STG there's a bit of magic
93 -- that recognises the seq# and eliminates the duff case.
96 seq :: Eval a => a -> b -> b
97 seq x y = case (seq# x) of { 0# -> seqError; _ -> y }
100 seqError = error "Oops! Entered seqError (a GHC bug -- please report it!)\n"
102 -- It is expected that compilers will recognize this and insert error
103 -- messages which are more appropriate to the context in which undefined
107 undefined = error "Prelude.undefined"