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