Typo
[packages/base.git] / Prelude.hs
1 {-# LANGUAGE Trustworthy #-}
2 {-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns #-}
3
4 -----------------------------------------------------------------------------
5 -- |
6 -- Module : Prelude
7 -- Copyright : (c) The University of Glasgow 2001
8 -- License : BSD-style (see the file libraries/base/LICENSE)
9 --
10 -- Maintainer : libraries@haskell.org
11 -- Stability : stable
12 -- Portability : portable
13 --
14 -- The Prelude: a standard module. The Prelude is imported by default
15 -- into all Haskell modules unless either there is an explicit import
16 -- statement for it, or the NoImplicitPrelude extension is enabled.
17 --
18 -----------------------------------------------------------------------------
19
20 module Prelude (
21
22 -- * Standard types, classes and related functions
23
24 -- ** Basic data types
25 Bool(False, True),
26 (&&), (||), not, otherwise,
27
28 Maybe(Nothing, Just),
29 maybe,
30
31 Either(Left, Right),
32 either,
33
34 Ordering(LT, EQ, GT),
35 Char, String,
36
37 -- *** Tuples
38 fst, snd, curry, uncurry,
39
40 -- ** Basic type classes
41 Eq((==), (/=)),
42 Ord(compare, (<), (<=), (>=), (>), max, min),
43 Enum(succ, pred, toEnum, fromEnum, enumFrom, enumFromThen,
44 enumFromTo, enumFromThenTo),
45 Bounded(minBound, maxBound),
46
47 -- ** Numbers
48
49 -- *** Numeric types
50 Int, Integer, Float, Double,
51 Rational,
52
53 -- *** Numeric type classes
54 Num((+), (-), (*), negate, abs, signum, fromInteger),
55 Real(toRational),
56 Integral(quot, rem, div, mod, quotRem, divMod, toInteger),
57 Fractional((/), recip, fromRational),
58 Floating(pi, exp, log, sqrt, (**), logBase, sin, cos, tan,
59 asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh),
60 RealFrac(properFraction, truncate, round, ceiling, floor),
61 RealFloat(floatRadix, floatDigits, floatRange, decodeFloat,
62 encodeFloat, exponent, significand, scaleFloat, isNaN,
63 isInfinite, isDenormalized, isIEEE, isNegativeZero, atan2),
64
65 -- *** Numeric functions
66 subtract, even, odd, gcd, lcm, (^), (^^),
67 fromIntegral, realToFrac,
68
69 -- ** Monads and functors
70 Monad((>>=), (>>), return, fail),
71 Functor(fmap),
72 mapM, mapM_, sequence, sequence_, (=<<),
73
74 -- ** Miscellaneous functions
75 id, const, (.), flip, ($), until,
76 asTypeOf, error, undefined,
77 seq, ($!),
78
79 -- * List operations
80 map, (++), filter,
81 head, last, tail, init, null, length, (!!),
82 reverse,
83 -- ** Reducing lists (folds)
84 foldl, foldl1, foldr, foldr1,
85 -- *** Special folds
86 and, or, any, all,
87 sum, product,
88 concat, concatMap,
89 maximum, minimum,
90 -- ** Building lists
91 -- *** Scans
92 scanl, scanl1, scanr, scanr1,
93 -- *** Infinite lists
94 iterate, repeat, replicate, cycle,
95 -- ** Sublists
96 take, drop, splitAt, takeWhile, dropWhile, span, break,
97 -- ** Searching lists
98 elem, notElem, lookup,
99 -- ** Zipping and unzipping lists
100 zip, zip3, zipWith, zipWith3, unzip, unzip3,
101 -- ** Functions on strings
102 lines, words, unlines, unwords,
103
104 -- * Converting to and from @String@
105 -- ** Converting to @String@
106 ShowS,
107 Show(showsPrec, showList, show),
108 shows,
109 showChar, showString, showParen,
110 -- ** Converting from @String@
111 ReadS,
112 Read(readsPrec, readList),
113 reads, readParen, read, lex,
114
115 -- * Basic Input and output
116 IO,
117 -- ** Simple I\/O operations
118 -- All I/O functions defined here are character oriented. The
119 -- treatment of the newline character will vary on different systems.
120 -- For example, two characters of input, return and linefeed, may
121 -- read as a single newline character. These functions cannot be
122 -- used portably for binary I/O.
123 -- *** Output functions
124 putChar,
125 putStr, putStrLn, print,
126 -- *** Input functions
127 getChar,
128 getLine, getContents, interact,
129 -- *** Files
130 FilePath,
131 readFile, writeFile, appendFile, readIO, readLn,
132 -- ** Exception handling in the I\/O monad
133 IOError, ioError, userError,
134
135 ) where
136
137 import Control.Monad
138 import System.IO
139 import System.IO.Error
140 import Data.List
141 import Data.Either
142 import Data.Maybe
143 import Data.Tuple
144
145 import GHC.Base
146 import Text.Read
147 import GHC.Enum
148 import GHC.Num
149 import GHC.Real
150 import GHC.Float
151 import GHC.Show
152
153 infixr 0 $!
154
155 -- -----------------------------------------------------------------------------
156 -- Miscellaneous functions
157
158 -- | Strict (call-by-value) application, defined in terms of 'seq'.
159 ($!) :: (a -> b) -> a -> b
160 f $! x = let !vx = x in f vx -- see #2273
161
162 #ifdef __HADDOCK__
163 -- | The value of @'seq' a b@ is bottom if @a@ is bottom, and otherwise
164 -- equal to @b@. 'seq' is usually introduced to improve performance by
165 -- avoiding unneeded laziness.
166 seq :: a -> b -> b
167 seq _ y = y
168 #endif