1 {-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns #-}
3 -----------------------------------------------------------------------------
6 -- Copyright : (c) The University of Glasgow 2001
7 -- License : BSD-style (see the file libraries/base/LICENSE)
9 -- Maintainer : libraries@haskell.org
11 -- Portability : portable
13 -- The Prelude: a standard module imported by default into all Haskell
14 -- modules. For more documentation, see the Haskell 98 Report
15 -- <http://www.haskell.org/onlinereport/>.
17 -----------------------------------------------------------------------------
21 -- * Standard types, classes and related functions
23 -- ** Basic data types
25 (&&), (||), not, otherwise,
37 fst, snd, curry, uncurry,
40 []((:), []), -- Not legal Haskell 98;
41 -- ... available through built-in syntax
42 module Data.Tuple, -- Includes tuple types
43 ()(..), -- Not legal Haskell 98
44 (->), -- ... available through built-in syntax
47 (:), -- Not legal Haskell 98
50 -- ** Basic type classes
52 Ord(compare, (<), (<=), (>=), (>), max, min),
53 Enum(succ, pred, toEnum, fromEnum, enumFrom, enumFromThen,
54 enumFromTo, enumFromThenTo),
55 Bounded(minBound, maxBound),
60 Int, Integer, Float, Double,
63 -- *** Numeric type classes
64 Num((+), (-), (*), negate, abs, signum, fromInteger),
66 Integral(quot, rem, div, mod, quotRem, divMod, toInteger),
67 Fractional((/), recip, fromRational),
68 Floating(pi, exp, log, sqrt, (**), logBase, sin, cos, tan,
69 asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh),
70 RealFrac(properFraction, truncate, round, ceiling, floor),
71 RealFloat(floatRadix, floatDigits, floatRange, decodeFloat,
72 encodeFloat, exponent, significand, scaleFloat, isNaN,
73 isInfinite, isDenormalized, isIEEE, isNegativeZero, atan2),
75 -- *** Numeric functions
76 subtract, even, odd, gcd, lcm, (^), (^^),
77 fromIntegral, realToFrac,
79 -- ** Monads and functors
80 Monad((>>=), (>>), return, fail),
82 mapM, mapM_, sequence, sequence_, (=<<),
84 -- ** Miscellaneous functions
85 id, const, (.), flip, ($), until,
86 asTypeOf, error, undefined,
91 head, last, tail, init, null, length, (!!),
93 -- ** Reducing lists (folds)
94 foldl, foldl1, foldr, foldr1,
102 scanl, scanl1, scanr, scanr1,
103 -- *** Infinite lists
104 iterate, repeat, replicate, cycle,
106 take, drop, splitAt, takeWhile, dropWhile, span, break,
107 -- ** Searching lists
108 elem, notElem, lookup,
109 -- ** Zipping and unzipping lists
110 zip, zip3, zipWith, zipWith3, unzip, unzip3,
111 -- ** Functions on strings
112 lines, words, unlines, unwords,
114 -- * Converting to and from @String@
115 -- ** Converting to @String@
117 Show(showsPrec, showList, show),
119 showChar, showString, showParen,
120 -- ** Converting from @String@
122 Read(readsPrec, readList),
123 reads, readParen, read, lex,
125 -- * Basic Input and output
127 -- ** Simple I\/O operations
128 -- All I/O functions defined here are character oriented. The
129 -- treatment of the newline character will vary on different systems.
130 -- For example, two characters of input, return and linefeed, may
131 -- read as a single newline character. These functions cannot be
132 -- used portably for binary I/O.
133 -- *** Output functions
135 putStr, putStrLn, print,
136 -- *** Input functions
138 getLine, getContents, interact,
141 readFile, writeFile, appendFile, readIO, readLn,
142 -- ** Exception handling in the I\/O monad
143 IOError, ioError, userError, catch
150 import System.IO.Error
157 #ifdef __GLASGOW_HASKELL__
160 -- import GHC.IO.Exception
167 import GHC.Err ( undefined )
178 -- -----------------------------------------------------------------------------
179 -- Miscellaneous functions
181 -- | Strict (call-by-value) application, defined in terms of 'seq'.
182 ($!) :: (a -> b) -> a -> b
183 #ifdef __GLASGOW_HASKELL__
184 f $! x = let !vx = x in f vx -- see #2273
185 #elif !defined(__HUGS__)
190 -- | The value of @'seq' a b@ is bottom if @a@ is bottom, and otherwise
191 -- equal to @b@. 'seq' is usually introduced to improve performance by
192 -- avoiding unneeded laziness.