Re-export `<$` from Prelude (#10113)
[ghc.git] / libraries / base / Prelude.hs
1 {-# LANGUAGE Trustworthy #-}
2 {-# LANGUAGE NoImplicitPrelude #-}
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, Word,
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 -- ** Monoids
70 Monoid(mempty, mappend, mconcat),
71
72 -- ** Monads and functors
73 Functor(fmap, (<$)), (<$>),
74 Applicative(pure, (<*>), (*>), (<*)),
75 Monad((>>=), (>>), return, fail),
76 mapM_, sequence_, (=<<),
77
78 -- ** Folds and traversals
79 Foldable(elem, -- :: (Foldable t, Eq a) => a -> t a -> Bool
80 -- fold, -- :: Monoid m => t m -> m
81 foldMap, -- :: Monoid m => (a -> m) -> t a -> m
82 foldr, -- :: (a -> b -> b) -> b -> t a -> b
83 -- foldr', -- :: (a -> b -> b) -> b -> t a -> b
84 foldl, -- :: (b -> a -> b) -> b -> t a -> b
85 -- foldl', -- :: (b -> a -> b) -> b -> t a -> b
86 foldr1, -- :: (a -> a -> a) -> t a -> a
87 foldl1, -- :: (a -> a -> a) -> t a -> a
88 maximum, -- :: (Foldable t, Ord a) => t a -> a
89 minimum, -- :: (Foldable t, Ord a) => t a -> a
90 product, -- :: (Foldable t, Num a) => t a -> a
91 sum), -- :: Num a => t a -> a
92 -- toList) -- :: Foldable t => t a -> [a]
93
94 Traversable(traverse, sequenceA, mapM, sequence),
95
96 -- ** Miscellaneous functions
97 id, const, (.), flip, ($), until,
98 asTypeOf, error, undefined,
99 seq, ($!),
100
101 -- * List operations
102 map, (++), filter,
103 head, last, tail, init, null, length, (!!),
104 reverse,
105 -- *** Special folds
106 and, or, any, all,
107 concat, concatMap,
108 -- ** Building lists
109 -- *** Scans
110 scanl, scanl1, scanr, scanr1,
111 -- *** Infinite lists
112 iterate, repeat, replicate, cycle,
113 -- ** Sublists
114 take, drop, splitAt, takeWhile, dropWhile, span, break,
115 -- ** Searching lists
116 notElem, lookup,
117 -- ** Zipping and unzipping lists
118 zip, zip3, zipWith, zipWith3, unzip, unzip3,
119 -- ** Functions on strings
120 lines, words, unlines, unwords,
121
122 -- * Converting to and from @String@
123 -- ** Converting to @String@
124 ShowS,
125 Show(showsPrec, showList, show),
126 shows,
127 showChar, showString, showParen,
128 -- ** Converting from @String@
129 ReadS,
130 Read(readsPrec, readList),
131 reads, readParen, read, lex,
132
133 -- * Basic Input and output
134 IO,
135 -- ** Simple I\/O operations
136 -- All I/O functions defined here are character oriented. The
137 -- treatment of the newline character will vary on different systems.
138 -- For example, two characters of input, return and linefeed, may
139 -- read as a single newline character. These functions cannot be
140 -- used portably for binary I/O.
141 -- *** Output functions
142 putChar,
143 putStr, putStrLn, print,
144 -- *** Input functions
145 getChar,
146 getLine, getContents, interact,
147 -- *** Files
148 FilePath,
149 readFile, writeFile, appendFile, readIO, readLn,
150 -- ** Exception handling in the I\/O monad
151 IOError, ioError, userError,
152
153 ) where
154
155 import Control.Monad
156 import System.IO
157 import System.IO.Error
158 import Data.List
159 import Data.Either
160 import Data.Foldable ( Foldable(..) )
161 import Data.Functor ( (<$>) )
162 import Data.Maybe
163 import Data.Traversable ( Traversable(..) )
164 import Data.Tuple
165
166 import GHC.Base hiding ( foldr, mapM, sequence )
167 import Text.Read
168 import GHC.Enum
169 import GHC.Num
170 import GHC.Real
171 import GHC.Float
172 import GHC.Show