[project @ 2003-08-30 12:26:56 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(__NHC__)
28 []((:), []), -- Not legal Haskell 98;
29 -- ... available through built-in syntax
30 module Data.Tuple, -- Includes tuple types
31 ()(..), -- Not legal Haskell 98
32 (->), -- ... available through built-in syntax
33 #endif
34 #ifdef __HUGS__
35 (:), -- Not legal Haskell 98
36 #endif
37
38 -- * Basic type classes
39 Eq((==), (/=)),
40 Ord(compare, (<), (<=), (>=), (>), max, min),
41 Enum(succ, pred, toEnum, fromEnum, enumFrom, enumFromThen,
42 enumFromTo, enumFromThenTo),
43 Bounded(minBound, maxBound),
44
45 -- * Numeric type classes
46 Num((+), (-), (*), negate, abs, signum, fromInteger),
47 Real(toRational),
48 Integral(quot, rem, div, mod, quotRem, divMod, toInteger),
49 Fractional((/), recip, fromRational),
50 Floating(pi, exp, log, sqrt, (**), logBase, sin, cos, tan,
51 asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh),
52 RealFrac(properFraction, truncate, round, ceiling, floor),
53 RealFloat(floatRadix, floatDigits, floatRange, decodeFloat,
54 encodeFloat, exponent, significand, scaleFloat, isNaN,
55 isInfinite, isDenormalized, isIEEE, isNegativeZero, atan2),
56
57 -- * List operations
58 map, (++), filter, concat,
59 head, last, tail, init, null, length, (!!),
60 foldl, foldl1, scanl, scanl1, foldr, foldr1, scanr, scanr1,
61 iterate, repeat, replicate, cycle,
62 take, drop, splitAt, takeWhile, dropWhile, span, break,
63 reverse, and, or,
64 any, all, elem, notElem, lookup,
65 maximum, minimum, concatMap,
66 zip, zip3, zipWith, zipWith3, unzip, unzip3,
67
68 lines, words, unlines, unwords,
69 sum, product,
70
71 -- * Converting to and from @String@
72 ReadS, ShowS,
73 Read(readsPrec, readList),
74 Show(showsPrec, showList, show),
75 reads, shows, read, lex,
76 showChar, showString, readParen, showParen,
77
78 -- * Basic Input and output
79 -- ** Simple I\/O operations
80 -- All I/O functions defined here are character oriented. The
81 -- treatment of the newline character will vary on different systems.
82 -- For example, two characters of input, return and linefeed, may
83 -- read as a single newline character. These functions cannot be
84 -- used portably for binary I/O.
85 -- *** Output functions
86 putChar,
87 putStr, putStrLn, print,
88 -- *** Input functions
89 getChar,
90 getLine, getContents, interact,
91 -- *** Files
92 FilePath,
93 readFile, writeFile, appendFile, readIO, readLn,
94 -- ** Exception handling in the I\/O monad
95 IOError, ioError, userError, catch,
96
97 -- * Monads
98 Monad((>>=), (>>), return, fail),
99 Functor(fmap),
100 mapM, mapM_, sequence, sequence_, (=<<),
101
102 -- * Miscellaneous functions
103 maybe, either,
104 (&&), (||), not, otherwise,
105 subtract, even, odd, gcd, lcm, (^), (^^),
106 fromIntegral, realToFrac,
107 fst, snd, curry, uncurry,
108 id, const, (.), flip, ($), until,
109 asTypeOf, error, undefined,
110 seq, ($!)
111
112 ) where
113
114 #ifndef __HUGS__
115 import Control.Monad
116 import System.IO
117 import Text.Read
118 import Text.Show
119 import Data.List
120 import Data.Either
121 import Data.Maybe
122 import Data.Bool
123 import Data.Tuple
124 #endif
125
126 #ifdef __GLASGOW_HASKELL__
127 import GHC.Base
128 import GHC.IOBase
129 import GHC.Exception
130 import GHC.Read
131 import GHC.Enum
132 import GHC.Num
133 import GHC.Real
134 import GHC.Float
135 import GHC.Show
136 import GHC.Err ( error, undefined )
137 #endif
138
139 #ifdef __HUGS__
140 import Hugs.Prelude
141 #endif
142
143 #ifndef __HUGS__
144 infixr 0 $!
145
146
147 -- -----------------------------------------------------------------------------
148 -- Miscellaneous functions
149
150 ($!) :: (a -> b) -> a -> b
151 f $! x = x `seq` f x
152 #endif
153