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