[project @ 1998-02-02 16:47:53 by simonm]
[ghc-hetmet.git] / ghc / lib / required / Prelude.lhs
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
4
5 \begin{code}
6 {-# OPTIONS -fno-implicit-prelude #-}
7
8 module Prelude (
9
10         -- Everything from these modules
11     module PrelList,
12     module PrelIO,
13     module PrelTup,
14
15         -- From PrelBase
16     (->),
17     Eq(..), 
18     Ord(..), Ordering(..), 
19     Bounded(..), 
20     Enum(..), succ, pred, 
21     Show(..), ShowS, shows, show, showChar, showString, showParen,
22     Eval(..), seq, strict,
23     Bool(..), (&&), (||), not, otherwise,
24     Char, String, Int, Integer, Float, Double, Void,
25     Maybe(..), maybe,
26     Either(..), either,
27     ()(..),             -- The unit type
28
29     
30     id, const, (.), flip, ($), until, asTypeOf, undefined,
31
32         -- From Error
33     error,
34
35         -- From Monad
36     Functor(..), Monad(..), MonadZero(..), MonadPlus(..),
37     accumulate, sequence, mapM, mapM_, guard, filter, concat, applyM,
38
39         -- From PrelRead
40     ReadS, Read(readsPrec, readList),
41     reads, read, lex, readParen, 
42
43         -- From PrelShow
44
45         -- From PrelNum
46     Ratio, Rational, 
47     (%), numerator, denominator, approxRational,
48
49     Num((+), (-), (*), negate, abs, signum, fromInteger, fromInt{-glaExt-}),
50     Real(toRational),
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
61   ) where
62
63 import PrelBase
64 import PrelList
65 import PrelIO
66 import PrelRead
67 import PrelNum
68 import PrelTup
69 import PrelMaybe
70 import PrelEither
71 import PrelBounded
72 import Monad
73 import Maybe
74 import GHCerr   ( error, seqError )
75
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.
78
79 strict      :: Eval a => (a -> b) -> a -> b
80 strict f x  = x `seq` f x
81
82
83 -- "seq" is defined a bit wierdly (see below)
84 --
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.  
90 --
91 -- Just before converting from Core to STG there's a bit of magic
92 -- that recognises the seq# and eliminates the duff case.
93
94 {-# INLINE seq  #-}
95 seq :: Eval a => a -> b -> b
96 seq  x y = case (seq#  x) of { 0# -> seqError; _ -> y }
97
98 -- It is expected that compilers will recognize this and insert error
99 -- messages which are more appropriate to the context in which undefined 
100 -- appears. 
101
102 undefined               :: a
103 undefined               =  error "Prelude.undefined"
104 \end{code}
105
106
107