[project @ 2002-09-10 10:50:28 by malcolm]
[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 ()(..), -- Not legal Haskell 98
32 (->), -- ... available through built-in syntax
33 #endif
34
35 module Data.Tuple,
36 -- Includes tuple types + fst, snd, curry, uncurry
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 -- * Simple I\/O operations
79 ioError, userError, catch,
80 FilePath, IOError,
81 putChar,
82 putStr, putStrLn, print,
83 getChar,
84 getLine, getContents, interact,
85 readFile, writeFile, appendFile, readIO, readLn,
86
87 -- * Monads
88 Monad((>>=), (>>), return, fail),
89 Functor(fmap),
90 mapM, mapM_, sequence, sequence_, (=<<),
91
92 -- * Miscellaneous functions
93 maybe, either,
94 (&&), (||), not, otherwise,
95 subtract, even, odd, gcd, lcm, (^), (^^),
96 fromIntegral, realToFrac,
97 --exported by Data.Tuple: fst, snd, curry, uncurry,
98 id, const, (.), flip, ($), until,
99 asTypeOf, error, undefined,
100 seq, ($!)
101
102 ) where
103
104 import Control.Monad
105 import System.IO
106 import Text.Read
107 import Text.Show
108 import Data.List
109 import Data.Either
110 import Data.Maybe
111 import Data.Bool
112 import Data.Tuple
113
114 #ifdef __GLASGOW_HASKELL__
115 import GHC.Base
116 import GHC.IOBase
117 import GHC.Exception
118 import GHC.Read
119 import GHC.Enum
120 import GHC.Num
121 import GHC.Real
122 import GHC.Float
123 import GHC.Show
124 import GHC.Conc
125 import GHC.Err ( error, undefined )
126 #endif
127
128 infixr 0 $!
129
130
131 -- -----------------------------------------------------------------------------
132 -- Miscellaneous functions
133
134 ($!) :: (a -> b) -> a -> b
135 f $! x = x `seq` f x
136
137