[project @ 2002-09-10 09:13:52 by ross]
[ghc-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 #ifdef __GLASGOW_HASKELL__
28         -- Restore export of (:) until we get to 5.05
29     []((:), []),        -- Not legal Haskell 98; available through built-in syntax
30 #endif
31     
32     module Data.Tuple,
33         -- Includes tuple types + fst, snd, curry, uncurry
34     -- ()(..),          -- Not legal Haskell 98
35     -- (->),            -- ... available through built-in syntax
36     
37     -- * Basic type classes
38     Eq((==), (/=)),
39     Ord(compare, (<), (<=), (>=), (>), max, min),
40     Enum(succ, pred, toEnum, fromEnum, enumFrom, enumFromThen,
41          enumFromTo, enumFromThenTo),
42     Bounded(minBound, maxBound),
43
44     -- * Numeric type classes
45     Num((+), (-), (*), negate, abs, signum, fromInteger),
46     Real(toRational),
47     Integral(quot, rem, div, mod, quotRem, divMod, toInteger),
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, atan2),
55
56     -- * List operations
57     map, (++), filter, concat,
58     head, last, tail, init, null, length, (!!), 
59     foldl, foldl1, scanl, scanl1, foldr, foldr1, scanr, scanr1,
60     iterate, repeat, replicate, cycle,
61     take, drop, splitAt, takeWhile, dropWhile, span, break,
62     reverse, and, or,
63     any, all, elem, notElem, lookup,
64     maximum, minimum, concatMap,
65     zip, zip3, zipWith, zipWith3, unzip, unzip3,
66
67     lines, words, unlines, unwords,
68     sum, product,
69
70     -- * Converting to and from @String@
71     ReadS, ShowS,
72     Read(readsPrec, readList),
73     Show(showsPrec, showList, show),
74     reads, shows, read, lex, 
75     showChar, showString, readParen, showParen,
76     
77     -- * Simple I\/O operations
78     ioError, userError, catch,
79     FilePath, IOError,
80     putChar,
81     putStr, putStrLn, print,
82     getChar,
83     getLine, getContents, interact,
84     readFile, writeFile, appendFile, readIO, readLn,
85
86     -- * Monads
87     Monad((>>=), (>>), return, fail),
88     Functor(fmap),
89     mapM, mapM_, sequence, sequence_, (=<<),
90
91     -- * Miscellaneous functions
92     maybe, either,
93     (&&), (||), not, otherwise,
94     subtract, even, odd, gcd, lcm, (^), (^^), 
95     fromIntegral, realToFrac,
96     --exported by Data.Tuple: fst, snd, curry, uncurry,
97     id, const, (.), flip, ($), until,
98     asTypeOf, error, undefined,
99     seq, ($!)
100
101   ) where
102
103 import Control.Monad
104 import System.IO
105 import Text.Read
106 import Text.Show
107 import Data.List
108 import Data.Either
109 import Data.Maybe
110 import Data.Bool
111 import Data.Tuple
112
113 #ifdef __GLASGOW_HASKELL__
114 import GHC.Base
115 import GHC.IOBase
116 import GHC.Exception
117 import GHC.Read
118 import GHC.Enum
119 import GHC.Num
120 import GHC.Real
121 import GHC.Float
122 import GHC.Show
123 import GHC.Conc
124 import GHC.Err   ( error, undefined )
125 #endif
126
127 infixr 0 $!
128
129
130 -- -----------------------------------------------------------------------------
131 -- Miscellaneous functions
132
133 ($!)    :: (a -> b) -> a -> b
134 f $! x  = x `seq` f x
135
136