[project @ 2003-07-29 12:03:13 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 #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     -- * 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     fst, snd, curry, uncurry,
98     id, const, (.), flip, ($), until,
99     asTypeOf, error, undefined,
100     seq, ($!)
101
102   ) where
103
104 #ifndef __HUGS__
105 import Control.Monad
106 import System.IO
107 import Text.Read
108 import Text.Show
109 import Data.List
110 import Data.Either
111 import Data.Maybe
112 import Data.Bool
113 import Data.Tuple
114 #endif
115
116 #ifdef __GLASGOW_HASKELL__
117 import GHC.Base
118 import GHC.IOBase
119 import GHC.Exception
120 import GHC.Read
121 import GHC.Enum
122 import GHC.Num
123 import GHC.Real
124 import GHC.Float
125 import GHC.Show
126 import GHC.Err   ( error, undefined )
127 #endif
128
129 #ifdef __HUGS__
130 import Hugs.Prelude
131 #endif
132
133 #ifndef __HUGS__
134 infixr 0 $!
135
136
137 -- -----------------------------------------------------------------------------
138 -- Miscellaneous functions
139
140 ($!)    :: (a -> b) -> a -> b
141 f $! x  = x `seq` f x
142 #endif
143