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