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