[project @ 2002-09-10 11:07:23 by ross]
[packages/base.git] / Prelude.hs
1 {-# OPTIONS -fno-implicit-prelude #-}
2 -----------------------------------------------------------------------------
3 -- |
4 -- Module : Prelude
5 -- Copyright : (c) The University of Glasgow 2001
6 -- License : BSD-style (see the file libraries/base/LICENSE)
7 --
8 -- Maintainer : libraries@haskell.org
9 -- Stability : provisional
10 -- Portability : portable
11 --
12 -- The Prelude: a standard module imported by default into all Haskell
13 -- modules. For more documentation, see the Haskell 98 Report
14 -- <http://www.haskell.org/onlinereport/>.
15 --
16 -----------------------------------------------------------------------------
17
18 module Prelude (
19
20 -- * Basic data types
21 Bool(False, True),
22 Maybe(Nothing, Just),
23 Either(Left, Right),
24 Ordering(LT, EQ, GT),
25 Char, String, Int, Integer, Float, Double, IO,
26 Rational,
27 #if defined(__GLASGOW_HASKELL__) || defined(__NHC__)
28 -- Restore export of (:) until we get to 5.05
29 []((:), []), -- Not legal Haskell 98;
30 -- ... available through built-in syntax
31 module Data.Tuple, -- Includes tuple types
32 ()(..), -- Not legal Haskell 98
33 (->), -- ... available through built-in syntax
34 #endif
35 #ifdef __HUGS__
36 (:), -- Not legal Haskell 98
37 #endif
38
39 -- * Basic type classes
40 Eq((==), (/=)),
41 Ord(compare, (<), (<=), (>=), (>), max, min),
42 Enum(succ, pred, toEnum, fromEnum, enumFrom, enumFromThen,
43 enumFromTo, enumFromThenTo),
44 Bounded(minBound, maxBound),
45
46 -- * Numeric type classes
47 Num((+), (-), (*), negate, abs, signum, fromInteger),
48 Real(toRational),
49 Integral(quot, rem, div, mod, quotRem, divMod, toInteger),
50 Fractional((/), recip, fromRational),
51 Floating(pi, exp, log, sqrt, (**), logBase, sin, cos, tan,
52 asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh),
53 RealFrac(properFraction, truncate, round, ceiling, floor),
54 RealFloat(floatRadix, floatDigits, floatRange, decodeFloat,
55 encodeFloat, exponent, significand, scaleFloat, isNaN,
56 isInfinite, isDenormalized, isIEEE, isNegativeZero, atan2),
57
58 -- * List operations
59 map, (++), filter, concat,
60 head, last, tail, init, null, length, (!!),
61 foldl, foldl1, scanl, scanl1, foldr, foldr1, scanr, scanr1,
62 iterate, repeat, replicate, cycle,
63 take, drop, splitAt, takeWhile, dropWhile, span, break,
64 reverse, and, or,
65 any, all, elem, notElem, lookup,
66 maximum, minimum, concatMap,
67 zip, zip3, zipWith, zipWith3, unzip, unzip3,
68
69 lines, words, unlines, unwords,
70 sum, product,
71
72 -- * Converting to and from @String@
73 ReadS, ShowS,
74 Read(readsPrec, readList),
75 Show(showsPrec, showList, show),
76 reads, shows, read, lex,
77 showChar, showString, readParen, showParen,
78
79 -- * Simple I\/O operations
80 ioError, userError, catch,
81 FilePath, IOError,
82 putChar,
83 putStr, putStrLn, print,
84 getChar,
85 getLine, getContents, interact,
86 readFile, writeFile, appendFile, readIO, readLn,
87
88 -- * Monads
89 Monad((>>=), (>>), return, fail),
90 Functor(fmap),
91 mapM, mapM_, sequence, sequence_, (=<<),
92
93 -- * Miscellaneous functions
94 maybe, either,
95 (&&), (||), not, otherwise,
96 subtract, even, odd, gcd, lcm, (^), (^^),
97 fromIntegral, realToFrac,
98 fst, snd, curry, uncurry,
99 id, const, (.), flip, ($), until,
100 asTypeOf, error, undefined,
101 seq, ($!)
102
103 ) where
104
105 #ifndef __HUGS__
106 import Control.Monad
107 import System.IO
108 import Text.Read
109 import Text.Show
110 import Data.List
111 import Data.Either
112 import Data.Maybe
113 import Data.Bool
114 import Data.Tuple
115 #endif
116
117 #ifdef __GLASGOW_HASKELL__
118 import GHC.Base
119 import GHC.IOBase
120 import GHC.Exception
121 import GHC.Read
122 import GHC.Enum
123 import GHC.Num
124 import GHC.Real
125 import GHC.Float
126 import GHC.Show
127 import GHC.Conc
128 import GHC.Err ( error, undefined )
129 #endif
130
131 #ifdef __HUGS__
132 import Hugs.Prelude
133 #endif
134
135 #ifndef __HUGS__
136 infixr 0 $!
137
138
139 -- -----------------------------------------------------------------------------
140 -- Miscellaneous functions
141
142 ($!) :: (a -> b) -> a -> b
143 f $! x = x `seq` f x
144 #endif
145