HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulebase-compat-batteries-0.14.1Haskell2010

Prelude.Compat

  • 17 types
  • 22 classes
  • 100 values
value(.) :: (b -> c) -> (a -> b) -> a -> c
#

Right to left function composition.

Property
(f . g) x = f (g x)
Property
f . id = f = id . f
Examples
Example1 expression
map ((*2) . length) [[], [0, 1, 2], [0]][0,6,2]
Example1 expression
foldr (.) id [(+1), (*3), (^3)] 225
Example1 expression
let (...) = (.).(.) in ((*2)...(+)) 5 1030
classclass Monad m => MonadFail (m :: Type -> Type) where
#

When a value is bound in do-notation, the pattern on the left hand side of <- might not match. In this case, this class provides a function to recover.

A Monad without a MonadFail instance may only be used in conjunction with pattern that always match, such as newtypes, tuples, data types with only a single data constructor, and irrefutable patterns (~pat).

Instances of MonadFail should satisfy the following law: fail s should be a left zero for >>=,

fail s >>= f  =  fail s

If your Monad is also MonadPlus, a popular definition is

fail _ = mzero

fail s should be an action that runs in the monad itself, not an exception (except in instances of MonadIO). In particular, fail should not be implemented in terms of error.

Methods

Instances25MonadFail, …
classclass Num a where
#

Basic numeric class.

The Haskell Report defines no laws for Num. However, (+) and (*) are customarily expected to define a ring and have the following properties:

Associativity of (+)

(x + y) + z

=

x + (y + z)

Commutativity of (+)

x + y

=

y + x

fromInteger 0 is the additive identity

x + fromInteger 0

=

x

negate gives the additive inverse

x + negate x

=

fromInteger 0

Associativity of (*)

(x * y) * z

=

x * (y * z)

fromInteger 1 is the multiplicative identity

x * fromInteger 1

=

x

and

fromInteger 1 * x

=

x

Distributivity of (*) with respect to (+)

a * (b + c)

=

(a * b) + (a * c)

and

(b + c) * a

=

(b * a) + (c * a)

Coherence with toInteger

if the type also implements

GHC.Real.Integral

, then

fromInteger

is a left inverse for

toInteger

, i.e.

fromInteger (toInteger i) == i

Note that it isn't customarily expected that a type instance of both Num and Ord implement an ordered ring. Indeed, in base only Integer and Rational do.

Methods

  • (+) :: a -> a -> ainfixl 6
  • (-) :: a -> a -> ainfixl 6
  • (*) :: a -> a -> ainfixl 7
  • negate :: a -> a

    Unary negation.

  • abs :: a -> a

    Absolute value.

  • signum :: a -> a

    Sign of a number. The functions abs and signum should satisfy the law:

    abs x * signum x == x

    For real numbers, the signum is either -1 (negative), 0 (zero) or 1 (positive).

  • fromInteger :: Integer -> a

    Conversion from an Integer. An integer literal represents the application of the function fromInteger to the appropriate value of type Integer, so such literals have type (Num a) => a.

Instances88Num, …
  • Num IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Num
  • Num NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Num

    Note that Natural's Num instance isn't a ring: no element but 0 has an additive inverse. It is a semiring though.

  • Num EventTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.EPoll
  • Num EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Poll
  • Num UniqueDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Unique
  • Num CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Num IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Num WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Num Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Num Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Num Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Num Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Num CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Num Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Num Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Num Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Num Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Num DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero. Neither addition nor multiplication are associative or distributive:

    Example3 expressions
    (0.1 + 0.1) + 0.4 == 0.1 + (0.1 + 0.4)False(0.1 + 0.2) * 0.3 == 0.1 * 0.3 + 0.2 * 0.3False(0.1 * 0.1) * 0.3 == 0.1 * (0.1 * 0.3)False
  • Num FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero. Neither addition nor multiplication are associative or distributive:

    Example3 expressions
    (0.1 + 0.1 :: Float) + 0.5 == 0.1 + (0.1 + 0.5)False(0.1 + 0.2 :: Float) * 0.9 == 0.1 * 0.9 + 0.2 * 0.9False(0.1 * 0.1 :: Float) * 0.9 == 0.1 * (0.1 * 0.9)False
  • Num IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Num
  • Num WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Num
  • Num DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Num NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Num CAttributesDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Num StatxFlagsDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Num StatxMaskDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Num BaudRateDefined in unix-2.8.7.0 · System.Posix.Terminal.Common
  • RealFloat a => Num (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Num a => Num (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Num a => Num (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Num a => Num (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Num a => Num (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Num a => Num (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Num a => Num (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Integral a => Num (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • HasResolution a => Num (Fixed a)Defined in base-4.20.2.0 · Data.Fixed

    Multiplication is not associative or distributive:

    Example1 expression
    (0.2 * 0.6 :: Deci) * 0.9 == 0.2 * (0.6 * 0.9)False
    Example1 expression
    (0.1 + 0.1 :: Deci) * 0.5 == 0.1 * 0.5 + 0.1 * 0.5False
  • Num a => Num (Op a b)Defined in base-4.20.2.0 · Data.Functor.Contravariant
  • Num (f a) => Num (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Num a => Num (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • (Applicative f, Num a) => Num (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid

    Note that even if the underlying Num and Applicative instances are lawful, for most Applicatives, this instance will not be lawful. If you use this instance with the list Applicative, the following customary laws will not hold:

    Commutativity:

    Example2 expressions
    Ap [10,20] + Ap [1,2]Ap {getAp = [11,12,21,22]}Ap [1,2] + Ap [10,20]Ap {getAp = [11,21,12,22]}

    Additive inverse:

    Example2 expressions
    Ap [] + negate (Ap [])Ap {getAp = []}fromInteger 0 :: Ap [] IntAp {getAp = [0]}

    Distributivity:

    Example2 expressions
    Ap [1,2] * (3 + 4)Ap {getAp = [7,14]}(Ap [1,2] * 3) + (Ap [1,2] * 4)Ap {getAp = [7,11,10,14]}
  • Num (f (g a)) => Num (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
valuemap :: (a -> b) -> [a] -> [b]
#

\mathcal{O}(n). map f xs is the list obtained by applying f to each element of xs, i.e.,

map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
map f [x1, x2, ...] == [f x1, f x2, ...]

this means that map id == id

Examples
Example1 expression
map (+1) [1, 2, 3][2,3,4]
Example1 expression
map id [1, 2, 3][1,2,3]
Example1 expression
map (\n -> 3 * n + 1) [1, 2, 3][4,7,10]
valuescanl :: (b -> a -> b) -> b -> [a] -> [b]
#

\mathcal{O}(n). scanl is similar to foldl, but returns a list of successive reduced values from the left:

scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]

Note that

last (scanl f z xs) == foldl f z xs
Examples
Example1 expression
scanl (+) 0 [1..4][0,1,3,6,10]
Example1 expression
scanl (+) 42 [][42]
Example1 expression
scanl (-) 100 [1..4][100,99,97,94,90]
Example1 expression
scanl (\reversedString nextChar -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd']["foo","afoo","bafoo","cbafoo","dcbafoo"]
Example1 expression
take 10 (scanl (+) 0 [1..])[0,1,3,6,10,15,21,28,36,45]
Example1 expression
take 1 (scanl undefined 'a' undefined)"a"
valuescanr :: (a -> b -> b) -> b -> [a] -> [b]
#

\mathcal{O}(n). scanr is the right-to-left dual of scanl. Note that the order of parameters on the accumulating function are reversed compared to scanl. Also note that

head (scanr f z xs) == foldr f z xs.
Examples
Example1 expression
scanr (+) 0 [1..4][10,9,7,4,0]
Example1 expression
scanr (+) 42 [][42]
Example1 expression
scanr (-) 100 [1..4][98,-97,99,-96,100]
Example1 expression
scanr (\nextChar reversedString -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd']["abcdfoo","bcdfoo","cdfoo","dfoo","foo"]
Example1 expression
force $ scanr (+) 0 [1..]*** Exception: stack overflow
valuescanl1 :: (a -> a -> a) -> [a] -> [a]
#

\mathcal{O}(n). scanl1 is a variant of scanl that has no starting value argument:

scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
Examples
Example1 expression
scanl1 (+) [1..4][1,3,6,10]
Example1 expression
scanl1 (+) [][]
Example1 expression
scanl1 (-) [1..4][1,-1,-4,-8]
Example1 expression
scanl1 (&&) [True, False, True, True][True,False,False,False]
Example1 expression
scanl1 (||) [False, False, True, True][False,False,True,True]
Example1 expression
take 10 (scanl1 (+) [1..])[1,3,6,10,15,21,28,36,45,55]
Example1 expression
take 1 (scanl1 undefined ('a' : undefined))"a"
valuescanr1 :: (a -> a -> a) -> [a] -> [a]
#

\mathcal{O}(n). scanr1 is a variant of scanr that has no starting value argument.

Examples
Example1 expression
scanr1 (+) [1..4][10,9,7,4]
Example1 expression
scanr1 (+) [][]
Example1 expression
scanr1 (-) [1..4][-2,3,-1,4]
Example1 expression
scanr1 (&&) [True, False, True, True][False,False,True,True]
Example1 expression
scanr1 (||) [True, True, False, False][True,True,False,False]
Example1 expression
force $ scanr1 (+) [1..]*** Exception: stack overflow
classclass Foldable (t :: Type -> Type) where
#

The Foldable class represents data structures that can be reduced to a summary value one element at a time. Strict left-associative folds are a good fit for space-efficient reduction, while lazy right-associative folds are a good fit for corecursive iteration, or for folds that short-circuit after processing an initial subsequence of the structure's elements.

Instances can be derived automatically by enabling the DeriveFoldable extension. For example, a derived instance for a binary tree might be:

{-# LANGUAGE DeriveFoldable #-}
data Tree a = Empty
            | Leaf a
            | Node (Tree a) a (Tree a)
    deriving Foldable

A more detailed description can be found in the Overview section of Data.Foldable#overview.

For the class laws see the Laws section of Data.Foldable#laws.

Methods

  • foldMap :: Monoid m => (a -> m) -> t a -> m

    Map each element of the structure into a monoid, and combine the results with (<>). This fold is right-associative and lazy in the accumulator. For strict left-associative folds consider foldMap' instead.

    Examples

    Basic usage:

    Example1 expression
    foldMap Sum [1, 3, 5]Sum {getSum = 9}
    Example1 expression
    foldMap Product [1, 3, 5]Product {getProduct = 15}
    Example1 expression
    foldMap (replicate 3) [1, 2, 3][1,1,1,2,2,2,3,3,3]

    When a Monoid's (<>) is lazy in its second argument, foldMap can return a result even from an unbounded structure. For example, lazy accumulation enables Data.ByteString.Builder to efficiently serialise large data structures and produce the output incrementally:

    Example5 expressions
    import qualified Data.ByteString.Lazy as Limport qualified Data.ByteString.Builder as Blet bld :: Int -> B.Builder; bld i = B.intDec i <> B.word8 0x20let lbs = B.toLazyByteString $ foldMap bld [0..]L.take 64 lbs"0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24"
  • foldr :: (a -> b -> b) -> b -> t a -> b

    Right-associative fold of a structure, lazy in the accumulator.

    In the case of lists, foldr, when applied to a binary operator, a starting value (typically the right-identity of the operator), and a list, reduces the list using the binary operator, from right to left:

    foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)

    Note that since the head of the resulting expression is produced by an application of the operator to the first element of the list, given an operator lazy in its right argument, foldr can produce a terminating expression from an unbounded list.

    For a general Foldable structure this should be semantically identical to,

    foldr f z = foldr f z . toList
    Examples

    Basic usage:

    Example1 expression
    foldr (||) False [False, True, False]True
    Example1 expression
    foldr (||) False []False
    Example1 expression
    foldr (\c acc -> acc ++ [c]) "foo" ['a', 'b', 'c', 'd']"foodcba"
    Infinite structures

    ⚠️ Applying foldr to infinite structures usually doesn't terminate.

    It may still terminate under one of the following conditions:

    • the folding function is short-circuiting

    • the folding function is lazy on its second argument

    Short-circuiting

    (||) short-circuits on True values, so the following terminates because there is a True value finitely far from the left side:

    Example1 expression
    foldr (||) False (True : repeat False)True

    But the following doesn't terminate:

    Example1 expression
    foldr (||) False (repeat False ++ [True])* Hangs forever *
    Laziness in the second argument

    Applying foldr to infinite structures terminates when the operator is lazy in its second argument (the initial accumulator is never used in this case, and so could be left undefined, but [] is more clear):

    Example1 expression
    take 5 $ foldr (\i acc -> i : fmap (+3) acc) [] (repeat 1)[1,4,7,10,13]
  • foldl :: (b -> a -> b) -> b -> t a -> b

    Left-associative fold of a structure, lazy in the accumulator. This is rarely what you want, but can work well for structures with efficient right-to-left sequencing and an operator that is lazy in its left argument.

    In the case of lists, foldl, when applied to a binary operator, a starting value (typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

    foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn

    Note that to produce the outermost application of the operator the entire input list must be traversed. Like all left-associative folds, foldl will diverge if given an infinite list.

    If you want an efficient strict left-fold, you probably want to use foldl' instead of foldl. The reason for this is that the latter does not force the inner results (e.g. z `f` x1 in the above example) before applying them to the operator (e.g. to (`f` x2)). This results in a thunk chain O(n) elements long, which then must be evaluated from the outside-in.

    For a general Foldable structure this should be semantically identical to:

    foldl f z = foldl f z . toList
    Examples

    The first example is a strict fold, which in practice is best performed with foldl'.

    Example1 expression
    foldl (+) 42 [1,2,3,4]52

    Though the result below is lazy, the input is reversed before prepending it to the initial accumulator, so corecursion begins only after traversing the entire input string.

    Example1 expression
    foldl (\acc c -> c : acc) "abcd" "efgh""hgfeabcd"

    A left fold of a structure that is infinite on the right cannot terminate, even when for any finite input the fold just returns the initial accumulator:

    Example1 expression
    foldl (\a _ -> a) 0 $ repeat 1* Hangs forever *

    WARNING: When it comes to lists, you always want to use either foldl' or foldr instead.

  • foldl' :: (b -> a -> b) -> b -> t a -> b

    Left-associative fold of a structure but with strict application of the operator.

    This ensures that each step of the fold is forced to Weak Head Normal Form before being applied, avoiding the collection of thunks that would otherwise occur. This is often what you want to strictly reduce a finite structure to a single strict result (e.g. sum).

    For a general Foldable structure this should be semantically identical to,

    foldl' f z = foldl' f z . toList
  • foldr1 :: (a -> a -> a) -> t a -> a

    A variant of foldr that has no base case, and thus may only be applied to non-empty structures.

    This function is non-total and will raise a runtime exception if the structure happens to be empty.

    Examples

    Basic usage:

    Example1 expression
    foldr1 (+) [1..4]10
    Example1 expression
    foldr1 (+) []Exception: Prelude.foldr1: empty list
    Example1 expression
    foldr1 (+) Nothing*** Exception: foldr1: empty structure
    Example1 expression
    foldr1 (-) [1..4]-2
    Example1 expression
    foldr1 (&&) [True, False, True, True]False
    Example1 expression
    foldr1 (||) [False, False, True, True]True
    Example1 expression
    foldr1 (+) [1..]* Hangs forever *
  • foldl1 :: (a -> a -> a) -> t a -> a

    A variant of foldl that has no base case, and thus may only be applied to non-empty structures.

    This function is non-total and will raise a runtime exception if the structure happens to be empty.

    foldl1 f = foldl1 f . toList
    Examples

    Basic usage:

    Example1 expression
    foldl1 (+) [1..4]10
    Example1 expression
    foldl1 (+) []*** Exception: Prelude.foldl1: empty list
    Example1 expression
    foldl1 (+) Nothing*** Exception: foldl1: empty structure
    Example1 expression
    foldl1 (-) [1..4]-8
    Example1 expression
    foldl1 (&&) [True, False, True, True]False
    Example1 expression
    foldl1 (||) [False, False, True, True]True
    Example1 expression
    foldl1 (+) [1..]* Hangs forever *
  • null :: t a -> Bool

    Test whether the structure is empty. The default implementation is Left-associative and lazy in both the initial element and the accumulator. Thus optimised for structures where the first element can be accessed in constant time. Structures where this is not the case should have a non-default implementation.

    Examples

    Basic usage:

    Example1 expression
    null []True
    Example1 expression
    null [1]False

    null is expected to terminate even for infinite structures. The default implementation terminates provided the structure is bounded on the left (there is a leftmost element).

    Example1 expression
    null [1..]False
  • length :: t a -> Int

    Returns the size/length of a finite structure as an Int. The default implementation just counts elements starting with the leftmost. Instances for structures that can compute the element count faster than via element-by-element counting, should provide a specialised implementation.

    Examples

    Basic usage:

    Example1 expression
    length []0
    Example2 expressions
    length ['a', 'b', 'c']3length [1..]* Hangs forever *
  • elem :: Eq a => a -> t a -> Boolinfix 4

    Does the element occur in the structure?

    Note: elem is often used in infix form.

    Examples

    Basic usage:

    Example1 expression
    3 `elem` []False
    Example1 expression
    3 `elem` [1,2]False
    Example1 expression
    3 `elem` [1,2,3,4,5]True

    For infinite structures, the default implementation of elem terminates if the sought-after value exists at a finite distance from the left side of the structure:

    Example1 expression
    3 `elem` [1..]True
    Example1 expression
    3 `elem` ([4..] ++ [3])* Hangs forever *
  • maximum :: Ord a => t a -> a

    The largest element of a non-empty structure.

    This function is non-total and will raise a runtime exception if the structure happens to be empty. A structure that supports random access and maintains its elements in order should provide a specialised implementation to return the maximum in faster than linear time.

    Examples

    Basic usage:

    Example1 expression
    maximum [1..10]10
    Example1 expression
    maximum []*** Exception: Prelude.maximum: empty list
    Example1 expression
    maximum Nothing*** Exception: maximum: empty structure

    WARNING: This function is partial for possibly-empty structures like lists.

  • minimum :: Ord a => t a -> a

    The least element of a non-empty structure.

    This function is non-total and will raise a runtime exception if the structure happens to be empty. A structure that supports random access and maintains its elements in order should provide a specialised implementation to return the minimum in faster than linear time.

    Examples

    Basic usage:

    Example1 expression
    minimum [1..10]1
    Example1 expression
    minimum []*** Exception: Prelude.minimum: empty list
    Example1 expression
    minimum Nothing*** Exception: minimum: empty structure

    WARNING: This function is partial for possibly-empty structures like lists.

  • sum :: Num a => t a -> a

    The sum function computes the sum of the numbers of a structure.

    Examples

    Basic usage:

    Example1 expression
    sum []0
    Example1 expression
    sum [42]42
    Example1 expression
    sum [1..10]55
    Example1 expression
    sum [4.1, 2.0, 1.7]7.8
    Example1 expression
    sum [1..]* Hangs forever *
  • product :: Num a => t a -> a

    The product function computes the product of the numbers of a structure.

    Examples

    Basic usage:

    Example1 expression
    product []1
    Example1 expression
    product [42]42
    Example1 expression
    product [1..10]3628800
    Example1 expression
    product [4.1, 2.0, 1.7]13.939999999999998
    Example1 expression
    product [1..]* Hangs forever *
Instances54Foldable, …
valuehead :: HasCallStack => [a] -> a
#

This is a partial function, it throws an error on empty lists. Use pattern matching, uncons or listToMaybe instead. Consider refactoring to use Data.List.NonEmpty.

\mathcal{O}(1). Extract the first element of a list, which must be non-empty.

To disable the warning about partiality put {-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-} at the top of the file. To disable it throughout a package put the same options into ghc-options section of Cabal file. To disable it in GHCi put :set -Wno-x-partial -Wno-unrecognised-warning-flags into ~/.ghci config file. See also the migration guide.

Examples
Example1 expression
head [1, 2, 3]1
Example1 expression
head [1..]1
Example1 expression
head []*** Exception: Prelude.head: empty list
valuetail :: HasCallStack => [a] -> [a]
#

This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or uncons instead. Consider refactoring to use Data.List.NonEmpty.

\mathcal{O}(1). Extract the elements after the head of a list, which must be non-empty.

To disable the warning about partiality put {-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-} at the top of the file. To disable it throughout a package put the same options into ghc-options section of Cabal file. To disable it in GHCi put :set -Wno-x-partial -Wno-unrecognised-warning-flags into ~/.ghci config file. See also the migration guide.

Examples
Example1 expression
tail [1, 2, 3][2,3]
Example1 expression
tail [1][]
Example1 expression
tail []*** Exception: Prelude.tail: empty list
valuelast :: HasCallStack => [a] -> a
#

\mathcal{O}(n). Extract the last element of a list, which must be finite and non-empty.

WARNING: This function is partial. Consider using unsnoc instead.

Examples
Example1 expression
last [1, 2, 3]3
Example1 expression
last [1..]* Hangs forever *
Example1 expression
last []*** Exception: Prelude.last: empty list
valueinit :: HasCallStack => [a] -> [a]
#

\mathcal{O}(n). Return all the elements of a list except the last one. The list must be non-empty.

WARNING: This function is partial. Consider using unsnoc instead.

Examples
Example1 expression
init [1, 2, 3][1,2]
Example1 expression
init [1][]
Example1 expression
init []*** Exception: Prelude.init: empty list
valuereverse :: [a] -> [a]
#

\mathcal{O}(n). reverse xs returns the elements of xs in reverse order. xs must be finite.

Laziness

reverse is lazy in its elements.

Example1 expression
head (reverse [undefined, 1])1
Example1 expression
reverse (1 : 2 : undefined)*** Exception: Prelude.undefined
Examples
Example1 expression
reverse [][]
Example1 expression
reverse [42][42]
Example1 expression
reverse [2,5,7][7,5,2]
Example1 expression
reverse [1..]* Hangs forever *
valueiterate :: (a -> a) -> a -> [a]
#

iterate f x returns an infinite list of repeated applications of f to x:

iterate f x == [x, f x, f (f x), ...]
Laziness

Note that iterate is lazy, potentially leading to thunk build-up if the consumer doesn't force each iterate. See iterate' for a strict variant of this function.

Example1 expression
take 1 $ iterate undefined 42[42]
Examples
Example1 expression
take 10 $ iterate not True[True,False,True,False,True,False,True,False,True,False]
Example1 expression
take 10 $ iterate (+3) 42[42,45,48,51,54,57,60,63,66,69]

iterate id == repeat:

Example1 expression
take 10 $ iterate id 1[1,1,1,1,1,1,1,1,1,1]
valuerepeat :: a -> [a]
#

repeat x is an infinite list, with x the value of every element.

Examples
Example1 expression
take 10 $ repeat 17[17,17,17,17,17,17,17,17,17, 17]
Example1 expression
repeat undefined[*** Exception: Prelude.undefined
valuecycle :: HasCallStack => [a] -> [a]
#

cycle ties a finite list into a circular one, or equivalently, the infinite repetition of the original list. It is the identity on infinite lists.

Examples
Example1 expression
cycle []*** Exception: Prelude.cycle: empty list
Example1 expression
take 10 (cycle [42])[42,42,42,42,42,42,42,42,42,42]
Example1 expression
take 10 (cycle [2, 5, 7])[2,5,7,2,5,7,2,5,7,2]
Example1 expression
take 1 (cycle (42 : undefined))[42]
valuetake :: Int -> [a] -> [a]
#

take n, applied to a list xs, returns the prefix of xs of length n, or xs itself if n >= length xs.

It is an instance of the more general genericTake, in which n may be of any integral type.

Laziness
Example2 expressions
take 0 undefined[]take 2 (1 : 2 : undefined)[1,2]
Examples
Example1 expression
take 5 "Hello World!""Hello"
Example1 expression
take 3 [1,2,3,4,5][1,2,3]
Example1 expression
take 3 [1,2][1,2]
Example1 expression
take 3 [][]
Example1 expression
take (-1) [1,2][]
Example1 expression
take 0 [1,2][]
valuedrop :: Int -> [a] -> [a]
#

drop n xs returns the suffix of xs after the first n elements, or [] if n >= length xs.

It is an instance of the more general genericDrop, in which n may be of any integral type.

Examples
Example1 expression
drop 6 "Hello World!""World!"
Example1 expression
drop 3 [1,2,3,4,5][4,5]
Example1 expression
drop 3 [1,2][]
Example1 expression
drop 3 [][]
Example1 expression
drop (-1) [1,2][1,2]
Example1 expression
drop 0 [1,2][1,2]
valuesplitAt :: Int -> [a] -> ([a], [a])
#

splitAt n xs returns a tuple where first element is xs prefix of length n and second element is the remainder of the list:

splitAt is an instance of the more general genericSplitAt, in which n may be of any integral type.

Laziness

It is equivalent to (take n xs, drop n xs) unless n is _|_: splitAt _|_ xs = _|_, not (_|_, _|_)).

The first component of the tuple is produced lazily:

Example1 expression
fst (splitAt 0 undefined)[]
Example1 expression
take 1 (fst (splitAt 10 (1 : undefined)))[1]
Examples
Example1 expression
splitAt 6 "Hello World!"("Hello ","World!")
Example1 expression
splitAt 3 [1,2,3,4,5]([1,2,3],[4,5])
Example1 expression
splitAt 1 [1,2,3]([1],[2,3])
Example1 expression
splitAt 3 [1,2,3]([1,2,3],[])
Example1 expression
splitAt 4 [1,2,3]([1,2,3],[])
Example1 expression
splitAt 0 [1,2,3]([],[1,2,3])
Example1 expression
splitAt (-1) [1,2,3]([],[1,2,3])
valuetakeWhile :: (a -> Bool) -> [a] -> [a]
#

takeWhile, applied to a predicate p and a list xs, returns the longest prefix (possibly empty) of xs of elements that satisfy p.

Laziness
Example1 expression
takeWhile (const False) undefined*** Exception: Prelude.undefined
Example1 expression
takeWhile (const False) (undefined : undefined)[]
Example1 expression
take 1 (takeWhile (const True) (1 : undefined))[1]
Examples
Example1 expression
takeWhile (< 3) [1,2,3,4,1,2,3,4][1,2]
Example1 expression
takeWhile (< 9) [1,2,3][1,2,3]
Example1 expression
takeWhile (< 0) [1,2,3][]
valuedropWhile :: (a -> Bool) -> [a] -> [a]
#

dropWhile p xs returns the suffix remaining after takeWhile p xs.

Examples
Example1 expression
dropWhile (< 3) [1,2,3,4,5,1,2,3][3,4,5,1,2,3]
Example1 expression
dropWhile (< 9) [1,2,3][]
Example1 expression
dropWhile (< 0) [1,2,3][1,2,3]
valuespan :: (a -> Bool) -> [a] -> ([a], [a])
#

span, applied to a predicate p and a list xs, returns a tuple where first element is the longest prefix (possibly empty) of xs of elements that satisfy p and second element is the remainder of the list:

span p xs is equivalent to (takeWhile p xs, dropWhile p xs), even if p is _|_.

Laziness
Example4 expressions
span undefined []([],[])fst (span (const False) undefined)*** Exception: Prelude.undefinedfst (span (const False) (undefined : undefined))[]take 1 (fst (span (const True) (1 : undefined)))[1]

span produces the first component of the tuple lazily:

Example1 expression
take 10 (fst (span (const True) [1..]))[1,2,3,4,5,6,7,8,9,10]
Examples
Example1 expression
span (< 3) [1,2,3,4,1,2,3,4]([1,2],[3,4,1,2,3,4])
Example1 expression
span (< 9) [1,2,3]([1,2,3],[])
Example1 expression
span (< 0) [1,2,3]([],[1,2,3])
valuebreak :: (a -> Bool) -> [a] -> ([a], [a])
#

break, applied to a predicate p and a list xs, returns a tuple where first element is longest prefix (possibly empty) of xs of elements that do not satisfy p and second element is the remainder of the list:

break p is equivalent to span (not . p) and consequently to (takeWhile (not . p) xs, dropWhile (not . p) xs), even if p is _|_.

Laziness
Example1 expression
break undefined []([],[])
Example1 expression
fst (break (const True) undefined)*** Exception: Prelude.undefined
Example1 expression
fst (break (const True) (undefined : undefined))[]
Example1 expression
take 1 (fst (break (const False) (1 : undefined)))[1]

break produces the first component of the tuple lazily:

Example1 expression
take 10 (fst (break (const False) [1..]))[1,2,3,4,5,6,7,8,9,10]
Examples
Example1 expression
break (> 3) [1,2,3,4,1,2,3,4]([1,2,3],[4,1,2,3,4])
Example1 expression
break (< 9) [1,2,3]([],[1,2,3])
Example1 expression
break (> 9) [1,2,3]([1,2,3],[])
valuefilter :: (a -> Bool) -> [a] -> [a]
#

\mathcal{O}(n). filter, applied to a predicate and a list, returns the list of those elements that satisfy the predicate; i.e.,

filter p xs = [ x | x <- xs, p x]
Examples
Example1 expression
filter odd [1, 2, 3][1,3]
Example1 expression
filter (\l -> length l > 3) ["Hello", ", ", "World", "!"]["Hello","World"]
Example1 expression
filter (/= 3) [1, 2, 3, 4, 3, 2, 1][1,2,4,2,1]
value(!!) :: HasCallStack => [a] -> Int -> a
#

List index (subscript) operator, starting from 0. It is an instance of the more general genericIndex, which takes an index of any integral type.

WARNING: This function is partial, and should only be used if you are sure that the indexing will not fail. Otherwise, use !?.

WARNING: This function takes linear time in the index.

Examples
Example1 expression
['a', 'b', 'c'] !! 0'a'
Example1 expression
['a', 'b', 'c'] !! 2'c'
Example1 expression
['a', 'b', 'c'] !! 3*** Exception: Prelude.!!: index too large
Example1 expression
['a', 'b', 'c'] !! (-1)*** Exception: Prelude.!!: negative index
valuezip :: [a] -> [b] -> [(a, b)]
#

\mathcal{O}(\min(m,n)). zip takes two lists and returns a list of corresponding pairs.

zip is right-lazy:

Example2 expressions
zip [] undefined[]zip undefined []*** Exception: Prelude.undefined...

zip is capable of list fusion, but it is restricted to its first list argument and its resulting list.

Examples
Example1 expression
zip [1, 2, 3] ['a', 'b', 'c'][(1,'a'),(2,'b'),(3,'c')]

If one input list is shorter than the other, excess elements of the longer list are discarded, even if one of the lists is infinite:

Example1 expression
zip [1] ['a', 'b'][(1,'a')]
Example1 expression
zip [1, 2] ['a'][(1,'a')]
Example1 expression
zip [] [1..][]
Example1 expression
zip [1..] [][]
valuezipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
#

\mathcal{O}(\min(m,n)). zipWith generalises zip by zipping with the function given as the first argument, instead of a tupling function.

zipWith (,) xs ys == zip xs ys
zipWith f [x1,x2,x3..] [y1,y2,y3..] == [f x1 y1, f x2 y2, f x3 y3..]

zipWith is right-lazy:

Example2 expressions
let f = undefinedzipWith f [] undefined[]

zipWith is capable of list fusion, but it is restricted to its first list argument and its resulting list.

Examples

zipWith (+) can be applied to two lists to produce the list of corresponding sums:

Example1 expression
zipWith (+) [1, 2, 3] [4, 5, 6][5,7,9]
Example1 expression
zipWith (++) ["hello ", "foo"] ["world!", "bar"]["hello world!","foobar"]
valueunzip :: [(a, b)] -> ([a], [b])
#

unzip transforms a list of pairs into a list of first components and a list of second components.

Examples
Example1 expression
unzip []([],[])
Example1 expression
unzip [(1, 'a'), (2, 'b')]([1,2],"ab")
classclass Semigroup a where
#

The class of semigroups (types with an associative binary operation).

Instances should satisfy the following:

Associativity

x <> (y <> z) = (x <> y) <> z

You can alternatively define sconcat instead of (<>), in which case the laws are:

Unit

sconcat (pure x) = x

Multiplication

sconcat (join xss) = sconcat (fmap sconcat xss)

Methods

  • (<>) :: a -> a -> ainfixr 6

    An associative operation.

    Examples
    Example1 expression
    [1,2,3] <> [4,5,6][1,2,3,4,5,6]
    Example1 expression
    Just [1, 2, 3] <> Just [4, 5, 6]Just [1,2,3,4,5,6]
    Example1 expression
    putStr "Hello, " <> putStrLn "World!"Hello, World!
Instances79Semigroup, …
valuefst :: (a, b) -> a
#

Extract the first component of a pair.

valuesnd :: (a, b) -> b
#

Extract the second component of a pair.

valuecurry :: ((a, b) -> c) -> a -> b -> c
#

Convert an uncurried function to a curried function.

Examples
Example1 expression
curry fst 1 21
valueuncurry :: (a -> b -> c) -> (a, b) -> c
#

uncurry converts a curried function to a function on pairs.

Examples
Example1 expression
uncurry (+) (1,2)3
Example1 expression
uncurry ($) (show, 1)"1"
Example1 expression
map (uncurry max) [(1,2), (3,4), (6,8)][2,4,8]
classclass Eq a where
#

The Eq class defines equality (==) and inequality (/=). All the basic datatypes exported by the Prelude are instances of Eq, and Eq may be derived for any datatype whose constituents are also instances of Eq.

The Haskell Report defines no laws for Eq. However, instances are encouraged to follow these properties:

Reflexivity

x == x

=

True

Symmetry

x == y

=

y == x

Transitivity

if

x == y && y == z

=

True

, then

x == z

=

True

Extensionality

if

x == y

=

True

and

f

is a function whose return type is an instance of

Eq

, then

f x == f y

=

True

Negation

x /= y

=

not (x == y)

Methods

Instances356Eq, …
  • Eq ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • Eq TimeoutDefined in base-4.20.2.0 · System.Timeout
  • Eq FloatingDecimalDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.RealFloat.D2S
  • Eq FloatingDecimalDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.RealFloat.F2S
  • Eq ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Eq ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • Eq ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • Eq BigNatDefined in ghc-bignum-1.3 · GHC.Num.BigNat
  • Eq IntegerDefined in ghc-bignum-1.3 · GHC.Num.Integer
  • Eq NaturalDefined in ghc-bignum-1.3 · GHC.Num.Natural
  • Eq ForeignSrcLangDefined in ghc-boot-th-9.10.3 · GHC.ForeignSrcLang.Type
  • Eq ExtensionDefined in ghc-boot-th-9.10.3 · GHC.LanguageExtensions.Type
  • Eq VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Eq ByteOrderDefined in ghc-internal-9.1003.0 · GHC.Internal.ByteOrder
  • Eq ClosureTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.ClosureTypes
  • Eq BlockReasonDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Eq ThreadIdDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Eq ThreadStatusDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Eq ConstrDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data

    Equality of constructors

  • Eq ConstrRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Eq DataRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Eq FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Eq AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Eq AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Eq SomeTypeRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Typeable.Internal
  • Eq UniqueDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Unique
  • Eq VersionDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Version
  • Eq ControlMessageDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Control
  • Eq EPollFdDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.EPoll
  • Eq EventTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.EPoll
  • Eq EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Eq EventLifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Eq LifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Eq FdKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Manager
  • Eq StateDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Manager
  • Eq EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Poll
  • Eq TimeoutKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.TimeOut
  • Eq StateDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.TimerManager
  • Eq UniqueDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Unique
  • Eq ErrorCallDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception
  • Eq ArithExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Type
  • Eq SpecConstrAnnotationDefined in ghc-internal-9.1003.0 · GHC.Internal.Exts
  • Eq FingerprintDefined in ghc-internal-9.1003.0 · GHC.Internal.Fingerprint.Type
  • Eq ErrnoDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Error
  • Eq CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Eq IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Eq WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Eq AssociativityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq DecidedStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq SourceStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq SourceUnpackednessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq MaskingStateDefined in ghc-internal-9.1003.0 · GHC.Internal.IO
  • Eq BufferStateDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Buffer
  • Eq IODeviceTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Eq SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Eq CodingProgressDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Encoding.Types
  • Eq ArrayExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Eq AsyncExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Eq ExitCodeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Eq IOErrorTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Eq IOExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Eq HandlePosnDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle
  • Eq BufferModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Eq HandleDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Eq NewlineDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Eq NewlineModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Eq IOModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.IOMode
  • Eq InfoProvDefined in ghc-internal-9.1003.0 · GHC.Internal.InfoProv.Types
  • Eq Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Eq Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Eq Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Eq Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Eq IoSubSystemDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Eq StackEntryDefined in ghc-internal-9.1003.0 · GHC.Internal.Stack.CloneStack
  • Eq SrcLocDefined in ghc-internal-9.1003.0 · GHC.Internal.Stack.Types
  • Eq CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CTimerDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Eq LexemeDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.Read.Lex
  • Eq NumberDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.Read.Lex
  • Eq SomeCharDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Eq SomeSymbolDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Eq SomeNatDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • Eq GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.Unicode
  • Eq Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Eq Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Eq Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Eq Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Eq BoolDefined in ghc-prim-0.12.0 · GHC.Classes
  • Eq CharDefined in ghc-prim-0.12.0 · GHC.Classes
  • Eq DoubleDefined in ghc-prim-0.12.0 · GHC.Classes

    Note that due to the presence of NaN, Double's Eq instance does not satisfy reflexivity.

    Example1 expression
    0/0 == (0/0 :: Double)False

    Also note that Double's Eq instance does not satisfy substitutivity:

    Example2 expressions
    0 == (-0 :: Double)Truerecip 0 == recip (-0 :: Double)False
  • Eq FloatDefined in ghc-prim-0.12.0 · GHC.Classes

    Note that due to the presence of NaN, Float's Eq instance does not satisfy reflexivity.

    Example1 expression
    0/0 == (0/0 :: Float)False

    Also note that Float's Eq instance does not satisfy extensionality:

    Example2 expressions
    0 == (-0 :: Float)Truerecip 0 == recip (-0 :: Float)False
  • Eq IntDefined in ghc-prim-0.12.0 · GHC.Classes
  • Eq ModuleDefined in ghc-prim-0.12.0 · GHC.Classes
  • Eq OrderingDefined in ghc-prim-0.12.0 · GHC.Classes
  • Eq TrNameDefined in ghc-prim-0.12.0 · GHC.Classes
  • Eq TyConDefined in ghc-prim-0.12.0 · GHC.Classes
  • Eq WordDefined in ghc-prim-0.12.0 · GHC.Classes
  • Eq EncodingExceptionDefined in os-string-2.0.7 · System.OsString.Encoding.Internal
  • Eq OsCharDefined in os-string-2.0.7 · System.OsString.Internal.Types

    Byte equality of the internal representation.

  • Eq OsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types

    Byte equality of the internal representation.

  • Eq PosixCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Eq PosixStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Eq WindowsCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Eq WindowsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Eq ModeDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Eq StyleDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Eq TextDetailsDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Eq PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Eq DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJ
  • Eq PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Eq TSemDefined in stm-2.5.3.1 · Control.Concurrent.STM.TSem
  • Eq AnnLookupDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq AnnTargetDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq BangDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq BndrVisDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq BodyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq BytesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq CallconvDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq ClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq ConDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq DecDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq DecidedStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq DerivClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq DerivStrategyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq DocLocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq ExpDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq FamilyResultSigDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq FixityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq FixityDirectionDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq ForeignDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq FunDepDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq GuardDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq InfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq InjectivityAnnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq InlineDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq LitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq LocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq MatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq ModNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq ModuleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq ModuleInfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq NameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq NameFlavourDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq NameSpaceDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq NamespaceSpecifierDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq OccNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq OverlapDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq PatDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq PatSynArgsDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq PatSynDirDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq PhasesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq PkgNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq PragmaDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq RangeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq RoleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq RuleBndrDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq RuleMatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq SafetyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq SourceStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq SourceUnpackednessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq SpecificityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq StmtDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq TyLitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq TySynEqnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq TypeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq TypeFamilyHeadDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq CalendarDiffDaysDefined in time-1.12.2 · Data.Time.Calendar.CalendarDiffDays
  • Eq DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • Eq MonthDefined in time-1.12.2 · Data.Time.Calendar.Month
  • Eq QuarterDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Eq QuarterOfYearDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Eq DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Eq FirstWeekTypeDefined in time-1.12.2 · Data.Time.Calendar.WeekDate
  • Eq AbsoluteTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.AbsoluteTime
  • Eq DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Eq NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Eq SystemTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.SystemTime
  • Eq UTCTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UTCTime
  • Eq UniversalTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UniversalTime
  • Eq TimeLocaleDefined in time-1.12.2 · Data.Time.Format.Locale
  • Eq CalendarDiffTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.CalendarDiffTime
  • Eq LocalTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.LocalTime
  • Eq TimeOfDayDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeOfDay
  • Eq TimeZoneDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeZone
  • Eq DirTypeDefined in unix-2.8.7.0 · System.Posix.Directory.Common
  • Eq AdviceDefined in unix-2.8.7.0 · System.Posix.Fcntl
  • Eq CAttributesDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Eq StatxFlagsDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Eq StatxMaskDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Eq OpenFileFlagsDefined in unix-2.8.7.0 · System.Posix.IO.Common
  • Eq OpenModeDefined in unix-2.8.7.0 · System.Posix.IO.Common
  • Eq ProcessStatusDefined in unix-2.8.7.0 · System.Posix.Process.Internals
  • Eq ResourceDefined in unix-2.8.7.0 · System.Posix.Resource
  • Eq ResourceLimitDefined in unix-2.8.7.0 · System.Posix.Resource
  • Eq ResourceLimitsDefined in unix-2.8.7.0 · System.Posix.Resource
  • Eq BaudRateDefined in unix-2.8.7.0 · System.Posix.Terminal.Common
  • Eq GroupEntryDefined in unix-2.8.7.0 · System.Posix.User.Common
  • Eq UserEntryDefined in unix-2.8.7.0 · System.Posix.User.Common
  • Eq ()Defined in ghc-prim-0.12.0 · GHC.Classes
  • Eq (Chan a)Defined in base-4.20.2.0 · Control.Concurrent.Chan
  • Eq (MutableByteArray s)Defined in base-4.20.2.0 · Data.Array.Byte
  • Eq (TVar a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Eq (ConstPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.ConstPtr
  • Eq (ForeignPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ForeignPtr
  • Eq (IOPort a)Defined in ghc-internal-9.1003.0 · GHC.Internal.IOPort
  • Eq (IORef a)Defined in ghc-internal-9.1003.0 · GHC.Internal.IORef

    Pointer equality.

  • Eq (MVar a)Defined in ghc-internal-9.1003.0 · GHC.Internal.MVar

    Compares the underlying pointers.

  • Eq (FunPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Eq (Ptr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Eq (StablePtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Stable
  • Eq (StableName a)Defined in ghc-internal-9.1003.0 · GHC.Internal.StableName
  • Eq (SChar c)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Eq (SSymbol s)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Eq (SNat n)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • Eq (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Eq (TBQueue a)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TBQueue
  • Eq (TChan a)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TChan
  • Eq (TMVar a)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TMVar
  • Eq (TQueue a)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TQueue
  • Eq (TVar a)Defined in stm-2.5.3.1 · Control.Sequential.STM
  • Eq a => Eq (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Eq a => Eq (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Eq a => Eq (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Eq a => Eq (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Eq a => Eq (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Eq a => Eq (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Eq a => Eq (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Eq a => Eq (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Eq a => Eq (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Eq a => Eq (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Eq a => Eq (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Eq a => Eq (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Eq a => Eq (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Eq a => Eq (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Eq a => Eq (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Eq a => Eq (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Eq a => Eq (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Eq a => Eq (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList
  • Eq a => Eq (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Maybe
  • Eq a => Eq (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Eq a => Eq (AnnotDetails a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Eq a => Eq (Span a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Eq a => Eq (a)Defined in ghc-prim-0.12.0 · GHC.Classes
  • Eq a => Eq [a]Defined in ghc-prim-0.12.0 · GHC.Classes
  • Eq flag => Eq (TyVarBndr flag)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq m => Eq (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Eq p => Eq (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (IOUArray i e)Defined in array-0.5.8.0 · Data.Array.IO.Internals
  • Eq (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Eq (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Eq (TypeRep a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Typeable.Internal
  • Eq (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (IOArray i e)Defined in ghc-internal-9.1003.0 · GHC.Internal.IOArray
  • Eq (STRef s a)Defined in ghc-internal-9.1003.0 · GHC.Internal.STRef

    Pointer equality.

  • Eq a => Eq (Arg a b)Defined in base-4.20.2.0 · Data.Semigroup
  • (Eq1 f, Eq a) => Eq (Lift f a)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • (Eq1 m, Eq a) => Eq (MaybeT m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • (Ix i, Eq e) => Eq (Array i e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Arr
  • (Ix ix, Eq e, IArray UArray e) => Eq (UArray ix e)Defined in array-0.5.8.0 · Data.Array.Base
  • (Eq a, Eq b) => Eq (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either
  • (Eq a, Eq b) => Eq (a, b)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Eq i, Eq e) => Eq (TArray i e)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TArray
  • Eq (STUArray s i e)Defined in array-0.5.8.0 · Data.Array.Base
  • Eq (STArray s i e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Arr
  • Eq (Coercion a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • Eq (OrderingI a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Ord
  • Eq (URec Char p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec Int p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec Word p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec (Ptr ()) p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Eq (f a) => Eq (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Eq (f a) => Eq (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Eq (f p) => Eq (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq a => Eq (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Eq a => Eq (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • (Eq1 f, Eq a) => Eq (Backwards f a)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • (Eq1 f, Eq a) => Eq (IdentityT f a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • (Eq1 f, Eq a) => Eq (Reverse f a)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • (Generic1 f, Eq (Rep1 f a)) => Eq (Generically1 f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Eq a, Eq b, Eq c) => Eq (a, b, c)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Eq e, Eq1 m, Eq a) => Eq (ExceptT e m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • (Eq w, Eq1 m, Eq a) => Eq (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Eq w, Eq1 m, Eq a) => Eq (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • Eq (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Eq c => Eq (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Eq (f a), Eq (g a)) => Eq (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Eq (f a), Eq (g a)) => Eq (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Eq (f p), Eq (g p)) => Eq ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Eq (f p), Eq (g p)) => Eq ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Eq a, Eq b, Eq c, Eq d) => Eq (a, b, c, d)Defined in ghc-prim-0.12.0 · GHC.Classes
  • Eq (f (g a)) => Eq (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Eq (f (g p)) => Eq ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (f p) => Eq (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Eq a, Eq b, Eq c, Eq d, Eq e) => Eq (a, b, c, d, e)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => Eq (a, b, c, d, e, f)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => Eq (a, b, c, d, e, f, g)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h) => Eq (a, b, c, d, e, f, g, h)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i) => Eq (a, b, c, d, e, f, g, h, i)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j) => Eq (a, b, c, d, e, f, g, h, i, j)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k) => Eq (a, b, c, d, e, f, g, h, i, j, k)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l) => Eq (a, b, c, d, e, f, g, h, i, j, k, l)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n, Eq o) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)Defined in ghc-prim-0.12.0 · GHC.Classes
value(<$>) :: Functor f => (a -> b) -> f a -> f b
#

An infix synonym for fmap.

The name of this operator is an allusion to Prelude.$. Note the similarities between their types:

 ($)  ::              (a -> b) ->   a ->   b
(<$>) :: Functor f => (a -> b) -> f a -> f b

Whereas Prelude.$ is function application, <$> is function application lifted over a Functor.

Examples

Convert from a Maybe Int to a Maybe String using show:

Example1 expression
show <$> NothingNothing
Example1 expression
show <$> Just 3Just "3"

Convert from an Either Int Int to an Either Int String using show:

Example1 expression
show <$> Left 17Left 17
Example1 expression
show <$> Right 17Right "17"

Double each element of a list:

Example1 expression
(*2) <$> [1,2,3][2,4,6]

Apply even to the second element of a pair:

Example1 expression
even <$> (2,2)(2,True)
classclass Functor (f :: Type -> Type) where
#

A type f is a Functor if it provides a function fmap which, given any types a and b lets you apply any function from (a -> b) to turn an f a into an f b, preserving the structure of f. Furthermore f needs to adhere to the following:

Identity

fmap id == id

Composition

fmap (f . g) == fmap f . fmap g

Note, that the second law follows from the free theorem of the type fmap and the first law, so you need only check that the former condition holds. See these articles by School of Haskell or David Luposchainsky for an explanation.

Methods

  • fmap :: (a -> b) -> f a -> f b

    fmap is used to apply a function of type (a -> b) to a value of type f a, where f is a functor, to produce a value of type f b. Note that for any type constructor with more than one parameter (e.g., Either), only the last type parameter can be modified with fmap (e.g., b in `Either a b`).

    Some type constructors with two parameters or more have a Data.Bifunctor instance that allows both the last and the penultimate parameters to be mapped over.

    Examples

    Convert from a Maybe Int to a Maybe String using show:

    Example2 expressions
    fmap show NothingNothingfmap show (Just 3)Just "3"

    Convert from an Either Int Int to an Either Int String using show:

    Example2 expressions
    fmap show (Left 17)Left 17fmap show (Right 17)Right "17"

    Double each element of a list:

    Example1 expression
    fmap (*2) [1,2,3][2,4,6]

    Apply even to the second element of a pair:

    Example1 expression
    fmap even (2,2)(2,True)

    It may seem surprising that the function is only applied to the last element of the tuple compared to the list example above which applies it to every element in the list. To understand, remember that tuples are type constructors with multiple type parameters: a tuple of 3 elements (a,b,c) can also be written (,,) a b c and its Functor instance is defined for Functor ((,,) a b) (i.e., only the third parameter is free to be mapped over with fmap).

    It explains why fmap can be used with tuples containing values of different types as in the following example:

    Example1 expression
    fmap even ("hello", 1.0, 4)("hello",1.0,True)
  • (<$) :: a -> f b -> f ainfixl 4

    Replace all locations in the input with the same value. The default definition is fmap . const, but this may be overridden with a more efficient version.

    Examples

    Perform a computation with Maybe and replace the result with a constant value if it is Just:

    Example2 expressions
    'a' <$ Just 2Just 'a''a' <$ NothingNothing
Instances100Functor, …
  • Functor ComplexDefined in base-4.20.2.0 · Data.Complex
  • Functor FirstDefined in base-4.20.2.0 · Data.Semigroup
  • Functor LastDefined in base-4.20.2.0 · Data.Semigroup
  • Functor MaxDefined in base-4.20.2.0 · Data.Semigroup
  • Functor MinDefined in base-4.20.2.0 · Data.Semigroup
  • Functor ArgDescrDefined in base-4.20.2.0 · System.Console.GetOpt
  • Functor ArgOrderDefined in base-4.20.2.0 · System.Console.GetOpt
  • Functor OptDescrDefined in base-4.20.2.0 · System.Console.GetOpt
  • Functor PutDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.Internal
  • Functor NonEmptyDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Functor STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Functor HandlerDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception
  • Functor IdentityDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Functor FirstDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Functor LastDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Functor DownDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Functor DualDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Functor ProductDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Functor SumDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Functor ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList
  • Functor NoIODefined in ghc-internal-9.1003.0 · GHC.Internal.GHCi
  • Functor Par1Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor MaybeDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Functor PDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadP
  • Functor ReadPDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadP
  • Functor ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrec
  • Functor SoloDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Functor IODefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Functor AnnotDetailsDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Functor DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Functor SpanDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Functor STMDefined in stm-2.5.3.1 · Control.Sequential.STM
  • Functor PprMDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.PprLib
  • Functor QDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Functor TyVarBndrDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Functor []Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Functor ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Functor U1Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor V1Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor (Arg a)Defined in base-4.20.2.0 · Data.Semigroup
  • Functor (Array i)Defined in ghc-internal-9.1003.0 · GHC.Internal.Arr
  • Functor (ST s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Monad.ST.Lazy.Imp
  • Functor (Either a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either
  • Functor (StateL s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils
  • Functor (StateR s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils
  • Functor (ST s)Defined in ghc-internal-9.1003.0 · GHC.Internal.ST
  • Functor (Tuple2 a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Functor f => Functor (Lift f)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • Functor m => Functor (MaybeT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • Monad m => Functor (WrappedMonad m)Defined in base-4.20.2.0 · Control.Applicative
  • Monad m => Functor (Handler m)Defined in exceptions-0.10.9 · Control.Monad.Catch
  • Monad m => Functor (CatchT m)Defined in exceptions-0.10.9 · Control.Monad.Catch.Pure
  • Arrow a => Functor (ArrowMonad a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Arrow
  • Functor (Const m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Functor (URec Char)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor (URec Double)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor (URec Float)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor (URec Int)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor (URec Word)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor (URec (Ptr ()))Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor (Tuple3 a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Functor (Constant a)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • Functor (t m) => Functor (LiftingAccum t m)Defined in mtl-2.3.1 · Control.Monad.Accum
  • Functor (t m) => Functor (LiftingSelect t m)Defined in mtl-2.3.1 · Control.Monad.Select
  • Functor f => Functor (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Functor f => Functor (Alt f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Functor f => Functor (Rec1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor f => Functor (Backwards f)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards

    Derived instance.

  • Functor f => Functor (Reverse f)Defined in transformers-0.6.1.1 · Data.Functor.Reverse

    Derived instance.

  • Functor m => Functor (Kleisli m a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Arrow
  • Functor m => Functor (AccumT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Accum
  • Functor m => Functor (ExceptT e m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • Functor m => Functor (IdentityT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • Functor m => Functor (ReaderT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Reader
  • Functor m => Functor (SelectT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Select
  • Functor m => Functor (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Lazy
  • Functor m => Functor (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Strict
  • Functor m => Functor (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.CPS
  • Functor m => Functor (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • Functor m => Functor (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • Monad m => Functor (StateT s m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils
  • Arrow a => Functor (WrappedArrow a b)Defined in base-4.20.2.0 · Control.Applicative
  • (Generic1 f, Functor (Rep1 f)) => Functor (Generically1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor (K1 i c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor (Tuple4 a b c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Functor (ContT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Cont
  • Functor ((->) r)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • (Functor f, Functor g) => Functor (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Functor f, Functor g) => Functor (Sum f g)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Functor f, Functor g) => Functor (f :*: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Functor f, Functor g) => Functor (f :+: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor (Tuple5 a b c d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Functor f => Functor (M1 i c f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor m => Functor (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.CPS
  • Functor m => Functor (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.Lazy
  • Functor m => Functor (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.Strict
  • (Functor f, Functor g) => Functor (Compose f g)Defined in base-4.20.2.0 · Data.Functor.Compose
  • (Functor f, Functor g) => Functor (f :.: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Functor (Tuple6 a b c d e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Functor (Tuple7 a b c d e f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
value(=<<) :: Monad m => (a -> m b) -> m a -> m b
#

Same as >>=, but with the arguments interchanged.

as >>= f == f =<< as
valueeither :: (a -> c) -> (b -> c) -> Either a b -> c
#

Case analysis for the Either type. If the value is Left a, apply the first function to a; if it is Right b, apply the second function to b.

Examples

We create two values of type Either String Int, one using the Left constructor and another using the Right constructor. Then we apply "either" the Prelude.length function (if we have a String) or the "times-two" function (if we have an Int):

Example4 expressions
let s = Left "foo" :: Either String Intlet n = Right 3 :: Either String Inteither length (*2) s3either length (*2) n6
valuemapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
#

Map each element of a structure to a monadic action, evaluate these actions from left to right, and ignore the results. For a version that doesn't ignore the results see Data.Traversable.mapM.

mapM_ is just like traverse_, but specialised to monadic actions.

valuesequence_ :: (Foldable t, Monad m) => t (m a) -> m ()
#

Evaluate each monadic action in the structure from left to right, and ignore the results. For a version that doesn't ignore the results see Data.Traversable.sequence.

sequence_ is just like sequenceA_, but specialised to monadic actions.

classclass (Functor t, Foldable t) => Traversable (t :: Type -> Type) where
#

Functors representing data structures that can be transformed to structures of the same shape by performing an Applicative (or, therefore, Monad) action on each element from left to right.

A more detailed description of what same shape means, the various methods, how traversals are constructed, and example advanced use-cases can be found in the Overview section of Data.Traversable#overview.

For the class laws see the Laws section of Data.Traversable#laws.

Methods

  • traverse :: Applicative f => (a -> f b) -> t a -> f (t b)

    Map each element of a structure to an action, evaluate these actions from left to right, and collect the results. For a version that ignores the results see traverse_.

    Examples

    Basic usage:

    In the first two examples we show each evaluated action mapping to the output structure.

    Example1 expression
    traverse Just [1,2,3,4]Just [1,2,3,4]
    Example1 expression
    traverse id [Right 1, Right 2, Right 3, Right 4]Right [1,2,3,4]

    In the next examples, we show that Nothing and Left values short circuit the created structure.

    Example1 expression
    traverse (const Nothing) [1,2,3,4]Nothing
    Example1 expression
    traverse (\x -> if odd x then Just x else Nothing)  [1,2,3,4]Nothing
    Example1 expression
    traverse id [Right 1, Right 2, Right 3, Right 4, Left 0]Left 0
  • sequenceA :: Applicative f => t (f a) -> f (t a)

    Evaluate each action in the structure from left to right, and collect the results. For a version that ignores the results see sequenceA_.

    Examples

    Basic usage:

    For the first two examples we show sequenceA fully evaluating a a structure and collecting the results.

    Example1 expression
    sequenceA [Just 1, Just 2, Just 3]Just [1,2,3]
    Example1 expression
    sequenceA [Right 1, Right 2, Right 3]Right [1,2,3]

    The next two example show Nothing and Just will short circuit the resulting structure if present in the input. For more context, check the Traversable instances for Either and Maybe.

    Example1 expression
    sequenceA [Just 1, Just 2, Just 3, Nothing]Nothing
    Example1 expression
    sequenceA [Right 1, Right 2, Right 3, Left 4]Left 4
  • mapM :: Monad m => (a -> m b) -> t a -> m (t b)

    Map each element of a structure to a monadic action, evaluate these actions from left to right, and collect the results. For a version that ignores the results see Data.Foldable.mapM_.

    Examples

    mapM is literally a traverse with a type signature restricted to Monad. Its implementation may be more efficient due to additional power of Monad.

  • sequence :: Monad m => t (m a) -> m (t a)

    Evaluate each monadic action in the structure from left to right, and collect the results. For a version that ignores the results see Data.Foldable.sequence_.

    Examples

    Basic usage:

    The first two examples are instances where the input and and output of sequence are isomorphic.

    Example1 expression
    sequence $ Right [1,2,3,4][Right 1,Right 2,Right 3,Right 4]
    Example1 expression
    sequence $ [Right 1,Right 2,Right 3,Right 4]Right [1,2,3,4]

    The following examples demonstrate short circuit behavior for sequence.

    Example1 expression
    sequence $ Left [1,2,3,4]Left [1,2,3,4]
    Example1 expression
    sequence $ [Left 0, Right 1,Right 2,Right 3,Right 4]Left 0
Instances54Traversable, …
datadata Bool
#
Instances25Bounded, Enum, Eq, Data, Ord, Read, …
  • Bounded BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Eq BoolDefined in ghc-prim-0.12.0 · GHC.Classes
  • Data BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Ord BoolDefined in ghc-prim-0.12.0 · GHC.Classes
  • Read BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Show BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Ix BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Generic BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Bits BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Bits

    Interpret Bool as 1-bit bit-field

  • FiniteBits BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Bits
  • Storable BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • SingKind BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • NFData BoolDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Pretty BoolDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Pretty BoolDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Lift BoolDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • SingI 'FalseDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • SingI 'TrueDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • IArray UArray BoolDefined in array-0.5.8.0 · Data.Array.Base
  • MArray IOUArray Bool IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • MArray (STUArray s) Bool (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • type Rep Bool = D1 ('MetaData "Bool" "GHC.Types" "ghc-prim" 'False) (C1 ('MetaCons "False" 'PrefixI 'False) U1 :+: C1 ('MetaCons "True" 'PrefixI 'False) U1)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • type DemoteRep Bool = BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • data Sing
    • STrue :: R:SingBoola 'True
    • SFalse :: R:SingBoola 'False
    Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
datadata Char
#

The character type Char represents Unicode codespace and its elements are code points as in definitions D9 and D10 of the Unicode Standard.

Character literals in Haskell are single-quoted: 'Q', 'Я' or 'Ω'. To represent a single quote itself use '\'', and to represent a backslash use '\\'. The full grammar can be found in the section 2.6 of the Haskell 2010 Language Report.

To specify a character by its code point one can use decimal, hexadecimal or octal notation: '\65', '\x41' and '\o101' are all alternative forms of 'A'. The largest code point is '\x10ffff'.

There is a special escape syntax for ASCII control characters:

Escape

Alternatives

Meaning

'\NUL'

'\0'

null character

'\SOH'

'\1'

start of heading

'\STX'

'\2'

start of text

'\ETX'

'\3'

end of text

'\EOT'

'\4'

end of transmission

'\ENQ'

'\5'

enquiry

'\ACK'

'\6'

acknowledge

'\BEL'

'\7'

,

'\a'

bell (alert)

'\BS'

'\8'

,

'\b'

backspace

'\HT'

'\9'

,

'\t'

horizontal tab

'\LF'

'\10'

,

'\n'

line feed (new line)

'\VT'

'\11'

,

'\v'

vertical tab

'\FF'

'\12'

,

'\f'

form feed

'\CR'

'\13'

,

'\r'

carriage return

'\SO'

'\14'

shift out

'\SI'

'\15'

shift in

'\DLE'

'\16'

data link escape

'\DC1'

'\17'

device control 1

'\DC2'

'\18'

device control 2

'\DC3'

'\19'

device control 3

'\DC4'

'\20'

device control 4

'\NAK'

'\21'

negative acknowledge

'\SYN'

'\22'

synchronous idle

'\ETB'

'\23'

end of transmission block

'\CAN'

'\24'

cancel

'\EM'

'\25'

end of medium

'\SUB'

'\26'

substitute

'\ESC'

'\27'

escape

'\FS'

'\28'

file separator

'\GS'

'\29'

group separator

'\RS'

'\30'

record separator

'\US'

'\31'

unit separator

'\SP'

'\32'

,

' '

space

'\DEL'

'\127'

delete

Data.Char provides utilities to work with Char.

Instances32Bounded, Enum, Data, Read, Ix, Storable, …
datadata Double
#

Double-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE double-precision type.

Instances32Enum, Floating, Fractional, Data, Num, Read, …
  • Enum DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    fromEnum just truncates its argument, beware of all sorts of overflows.

    List generators have extremely peculiar behavior, mandated by Haskell Report 2010:

    Example1 expression
    [0..1.5][0.0,1.0,2.0]
  • Eq DoubleDefined in ghc-prim-0.12.0 · GHC.Classes

    Note that due to the presence of NaN, Double's Eq instance does not satisfy reflexivity.

    Example1 expression
    0/0 == (0/0 :: Double)False

    Also note that Double's Eq instance does not satisfy substitutivity:

    Example2 expressions
    0 == (-0 :: Double)Truerecip 0 == recip (-0 :: Double)False
  • Floating DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float
  • Fractional DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero.

    Example4 expressions
    0 == (-0 :: Double)Truerecip 0 == recip (-0 :: Double)Falsemap (/ 0) [-1, 0, 1][-Infinity,NaN,Infinity]map (* 0) $ map (/ 0) [-1, 0, 1][NaN,NaN,NaN]
  • Data DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero. Neither addition nor multiplication are associative or distributive:

    Example3 expressions
    (0.1 + 0.1) + 0.4 == 0.1 + (0.1 + 0.4)False(0.1 + 0.2) * 0.3 == 0.1 * 0.3 + 0.2 * 0.3False(0.1 * 0.1) * 0.3 == 0.1 * (0.1 * 0.3)False
  • Ord DoubleDefined in ghc-prim-0.12.0 · GHC.Classes

    IEEE 754 Double-precision type includes not only numbers, but also positive and negative infinities and a special element called NaN (which can be quiet or signal).

    IEEE 754-2008, section 5.11 requires that if at least one of arguments of <=, <, >, >= is NaN then the result of the comparison is False, and instance Ord Double complies with this requirement. This violates the reflexivity: both NaN <= NaN and NaN >= NaN are False.

    IEEE 754-2008, section 5.10 defines totalOrder predicate. Unfortunately, compare on Doubles violates the IEEE standard and does not define a total order. More specifically, both compare NaN x and compare x NaN always return GT.

    Thus, users must be extremely cautious when using instance Ord Double. For instance, one should avoid ordered containers with keys represented by Double, because data loss and corruption may happen. An IEEE-compliant compare is available in fp-ieee package as TotallyOrdered newtype.

    Moving further, the behaviour of min and max with regards to NaN is also non-compliant. IEEE 754-2008, section 5.3.1 defines that quiet NaN should be treated as a missing data by minNum and maxNum functions, for example, minNum(NaN, 1) = minNum(1, NaN) = 1. Some languages such as Java deviate from the standard implementing minNum(NaN, 1) = minNum(1, NaN) = NaN. However, min / max in base are even worse: min NaN 1 is 1, but min 1 NaN is NaN.

    IEEE 754-2008 compliant min / max can be found in ieee754 package under minNum / maxNum names. Implementations compliant with minimumNumber / maximumNumber from a newer IEEE 754-2019, section 9.6 are available from fp-ieee package.

  • Read DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Real DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that toRational generates garbage for non-finite arguments:

    Example2 expressions
    toRational (1/0)179769313 (and 300 more digits...) % 1toRational (0/0)269653970 (and 300 more digits...) % 1
  • RealFloat DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float
  • RealFrac DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that results for non-finite arguments are garbage:

    Example2 expressions
    [ f x | f <- [round, floor, ceiling], x <- [-1/0, 0/0, 1/0] ] :: [Int][0,0,0,0,0,0,0,0,0]map properFraction [-1/0, 0/0, 1/0] :: [(Int, Double)][(0,0.0),(0,0.0),(0,0.0)]

    and get even more non-sensical if you ask for Integer instead of Int.

  • Show DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan
  • Storable DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • PrintfArg DoubleDefined in base-4.20.2.0 · Text.Printf
  • NFData DoubleDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Pretty DoubleDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Pretty DoubleDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Lift DoubleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • IArray UArray DoubleDefined in array-0.5.8.0 · Data.Array.Base
  • MArray IOUArray Double IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • Generic1 (URec Double)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Foldable UDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Foldable
  • Traversable UDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Traversable
  • MArray (STUArray s) Double (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • Functor (URec Double)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • type Rep (URec Double p) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UDouble" 'PrefixI 'True) (S1 ('MetaSel ('Just "uDouble#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UDouble))Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • type Rep1 (URec Double) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UDouble" 'PrefixI 'True) (S1 ('MetaSel ('Just "uDouble#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UDouble))Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • data URec DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics

    Used for marking occurrences of Double#

datadata Float
#

Single-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE single-precision type.

Instances32Enum, Floating, Fractional, Data, Num, Read, …
  • Enum FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    fromEnum just truncates its argument, beware of all sorts of overflows.

    List generators have extremely peculiar behavior, mandated by Haskell Report 2010:

    Example1 expression
    [0..1.5 :: Float][0.0,1.0,2.0]
  • Eq FloatDefined in ghc-prim-0.12.0 · GHC.Classes

    Note that due to the presence of NaN, Float's Eq instance does not satisfy reflexivity.

    Example1 expression
    0/0 == (0/0 :: Float)False

    Also note that Float's Eq instance does not satisfy extensionality:

    Example2 expressions
    0 == (-0 :: Float)Truerecip 0 == recip (-0 :: Float)False
  • Floating FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float
  • Fractional FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero.

    Example4 expressions
    0 == (-0 :: Float)Truerecip 0 == recip (-0 :: Float)Falsemap (/ 0) [-1, 0, 1 :: Float][-Infinity,NaN,Infinity]map (* 0) $ map (/ 0) [-1, 0, 1 :: Float][NaN,NaN,NaN]
  • Data FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero. Neither addition nor multiplication are associative or distributive:

    Example3 expressions
    (0.1 + 0.1 :: Float) + 0.5 == 0.1 + (0.1 + 0.5)False(0.1 + 0.2 :: Float) * 0.9 == 0.1 * 0.9 + 0.2 * 0.9False(0.1 * 0.1 :: Float) * 0.9 == 0.1 * (0.1 * 0.9)False
  • Ord FloatDefined in ghc-prim-0.12.0 · GHC.Classes

    See instance Ord Double for discussion of deviations from IEEE 754 standard.

  • Read FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Real FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that toRational generates garbage for non-finite arguments:

    Example2 expressions
    toRational (1/0 :: Float)340282366920938463463374607431768211456 % 1toRational (0/0 :: Float)510423550381407695195061911147652317184 % 1
  • RealFloat FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float
  • RealFrac FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that results for non-finite arguments are garbage:

    Example2 expressions
    [ f x | f <- [round, floor, ceiling], x <- [-1/0, 0/0, 1/0 :: Float] ] :: [Int][0,0,0,0,0,0,0,0,0]map properFraction [-1/0, 0/0, 1/0] :: [(Int, Float)][(0,0.0),(0,0.0),(0,0.0)]

    and get even more non-sensical if you ask for Integer instead of Int.

  • Show FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan
  • Storable FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • PrintfArg FloatDefined in base-4.20.2.0 · Text.Printf
  • NFData FloatDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Pretty FloatDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Pretty FloatDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Lift FloatDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • IArray UArray FloatDefined in array-0.5.8.0 · Data.Array.Base
  • MArray IOUArray Float IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • Generic1 (URec Float)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Foldable UFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Foldable
  • Traversable UFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Traversable
  • MArray (STUArray s) Float (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • Functor (URec Float)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • type Rep (URec Float p) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UFloat" 'PrefixI 'True) (S1 ('MetaSel ('Just "uFloat#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UFloat))Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • type Rep1 (URec Float) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UFloat" 'PrefixI 'True) (S1 ('MetaSel ('Just "uFloat#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UFloat))Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • data URec FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics

    Used for marking occurrences of Float#

datadata Int
#

A fixed-precision integer type with at least the range [-2^29 .. 2^29-1]. The exact range for a given implementation can be determined by using Prelude.minBound and Prelude.maxBound from the Prelude.Bounded class.

Instances34Bounded, Enum, Integral, Data, Num, Read, …
datadata Word
#

A Word is an unsigned integral type, with the same size as Int.

Instances31Bounded, Enum, Integral, Data, Num, Read, …
datadata Ordering
#
Instances15Bounded, Enum, Eq, Data, Ord, Read, …
datadata Maybe a
#

The Maybe type encapsulates an optional value. A value of type Maybe a either contains a value of type a (represented as Just a), or it is empty (represented as Nothing). Using Maybe is a good way to deal with errors or exceptional cases without resorting to drastic measures such as error.

The Maybe type is also a monad. It is a simple kind of error monad, where all errors are represented by Nothing. A richer error monad can be built using the Either type.

Constructors

Instances37Monad, Functor, MonadFix, MonadFail, Applicative, Foldable, …
classclass a ~ b => (~) (a :: k) (b :: k)
#

Lifted, homogeneous equality. By lifted, we mean that it can be bogus (deferred type error). By homogeneous, the two types a and b must have the same kinds.

datadata Integer
#

Arbitrary precision integers. In contrast with fixed-size integral types such as Int, the Integer type represents the entire infinite range of integers.

Integers are stored in a kind of sign-magnitude form, hence do not expect two's complement form when using bit operations.

If the value is small (i.e., fits into an Int), the IS constructor is used. Otherwise IP and IN constructors are used to store a BigNat representing the positive or the negative value magnitude, respectively.

Invariant: IP and IN are used iff the value does not fit in IS.

Instances18Enum, Eq, Integral, Data, Num, Ord, …
  • Enum IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Eq IntegerDefined in ghc-bignum-1.3 · GHC.Num.Integer
  • Integral IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Data IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Num
  • Ord IntegerDefined in ghc-bignum-1.3 · GHC.Num.Integer
  • Read IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Real IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Show IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Ix IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Bits IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Bits
  • PrintfArg IntegerDefined in base-4.20.2.0 · Text.Printf
  • NFData IntegerDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Pretty IntegerDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Pretty IntegerDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • DayPeriod YearDefined in time-1.12.2 · Data.Time.Calendar.Gregorian · orphan
  • ShowPadded IntegerDefined in time-1.12.2 · Data.Time.Calendar.Private
  • Lift IntegerDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
value($) :: (a -> b) -> a -> b
#

($) is the function application operator.

Applying ($) to a function f and an argument x gives the same result as applying f to x directly. The definition is akin to this:

($) :: (a -> b) -> a -> b
($) f x = f x

This is id specialized from a -> a to (a -> b) -> (a -> b) which by the associativity of (->) is the same as (a -> b) -> a -> b.

On the face of it, this may appear pointless! But it's actually one of the most useful and important operators in Haskell.

The order of operations is very different between ($) and normal function application. Normal function application has precedence 10 - higher than any operator - and associates to the left. So these two definitions are equivalent:

expr = min 5 1 + 5
expr = ((min 5) 1) + 5

($) has precedence 0 (the lowest) and associates to the right, so these are equivalent:

expr = min 5 $ 1 + 5
expr = (min 5) (1 + 5)
Examples

A common use cases of ($) is to avoid parentheses in complex expressions.

For example, instead of using nested parentheses in the following Haskell function:

-- | Sum numbers in a string: strSum "100  5 -7" == 98
strSum :: String -> Int
strSum s = sum (mapMaybe readMaybe (words s))

we can deploy the function application operator:

-- | Sum numbers in a string: strSum "100  5 -7" == 98
strSum :: String -> Int
strSum s = sum $ mapMaybe readMaybe $ words s

($) is also used as a section (a partially applied operator), in order to indicate that we wish to apply some yet-unspecified function to a given value. For example, to apply the argument 5 to a list of functions:

applyFive :: [Int]
applyFive = map ($ 5) [(+1), (2^)]
>>> [6, 32]
Technical Remark (Representation Polymorphism)

($) is fully representation-polymorphic. This allows it to also be used with arguments of unlifted and even unboxed kinds, such as unboxed integers:

fastMod :: Int -> Int -> Int
fastMod (I# x) (I# m) = I# $ remInt# x m
valueotherwise :: Bool
#

otherwise is defined as the value True. It helps to make guards more readable. eg.

 f x | x < 0     = ...
     | otherwise = ...
value(++) :: [a] -> [a] -> [a]
#

(++) appends two lists, i.e.,

[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
[x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]

If the first list is not finite, the result is the first list.

Performance considerations

This function takes linear time in the number of elements of the first list. Thus it is better to associate repeated applications of (++) to the right (which is the default behaviour): xs ++ (ys ++ zs) or simply xs ++ ys ++ zs, but not (xs ++ ys) ++ zs. For the same reason GHC.Internal.Data.List.concat = GHC.Internal.Data.List.foldr (++) [] has linear performance, while GHC.Internal.Data.List.foldl (++) [] is prone to quadratic slowdown

Examples
Example1 expression
[1, 2, 3] ++ [4, 5, 6][1,2,3,4,5,6]
Example1 expression
[] ++ [1, 2, 3][1,2,3]
Example1 expression
[3, 2, 1] ++ [][3,2,1]
classclass Applicative m => Monad (m :: Type -> Type) where
#

The Monad class defines the basic operations over a monad, a concept from a branch of mathematics known as category theory. From the perspective of a Haskell programmer, however, it is best to think of a monad as an abstract datatype of actions. Haskell's do expressions provide a convenient syntax for writing monadic expressions.

Instances of Monad should satisfy the following:

Left identity

return a >>= k = k a

Right identity

m >>= return = m

Associativity

m >>= (\x -> k x >>= h) = (m >>= k) >>= h

Furthermore, the Monad and Applicative operations should relate as follows:

The above laws imply:

and that pure and (<*>) satisfy the applicative functor laws.

The instances of Monad for GHC.List.List, Maybe and System.IO.IO defined in the Prelude satisfy these laws.

Methods

  • (>>=) :: m a -> (a -> m b) -> m binfixl 1

    Sequentially compose two actions, passing any value produced by the first as an argument to the second.

    'as >>= bs' can be understood as the do expression

    do a <- as
       bs a
    

    An alternative name for this function is 'bind', but some people may refer to it as 'flatMap', which results from it being equivialent to

    \x f -> join (fmap f x) :: Monad m => m a -> (a -> m b) -> m b

    which can be seen as mapping a value with Monad m => m a -> m (m b) and then 'flattening' m (m b) to m b using join.

  • (>>) :: m a -> m b -> m binfixl 1

    Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.

    'as >> bs' can be understood as the do expression

    do as
       bs
    

    or in terms of (>>=) as

    as >>= const bs
  • return :: a -> m a

    Inject a value into the monadic type. This function should not be different from its default implementation as pure. The justification for the existence of this function is merely historic.

Instances65Monad, …
  • Monad ComplexDefined in base-4.20.2.0 · Data.Complex
  • Monad FirstDefined in base-4.20.2.0 · Data.Semigroup
  • Monad LastDefined in base-4.20.2.0 · Data.Semigroup
  • Monad MaxDefined in base-4.20.2.0 · Data.Semigroup
  • Monad MinDefined in base-4.20.2.0 · Data.Semigroup
  • Monad PutDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.Internal
  • Monad NonEmptyDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monad STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Monad IdentityDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Monad FirstDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monad LastDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monad DownDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Monad DualDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monad ProductDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monad SumDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monad NoIODefined in ghc-internal-9.1003.0 · GHC.Internal.GHCi
  • Monad Par1Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monad MaybeDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monad PDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadP
  • Monad ReadPDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadP
  • Monad ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrec
  • Monad SoloDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monad IODefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monad STMDefined in stm-2.5.3.1 · Control.Sequential.STM
  • Monad PprMDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.PprLib
  • Monad QDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Monad []Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monad ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Monad U1Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monad (ST s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Monad.ST.Lazy.Imp
  • Monad (Either e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either
  • Monad (ST s)Defined in ghc-internal-9.1003.0 · GHC.Internal.ST
  • Monad m => Monad (WrappedMonad m)Defined in base-4.20.2.0 · Control.Applicative
  • Monad m => Monad (CatchT m)Defined in exceptions-0.10.9 · Control.Monad.Catch.Pure
  • Monad m => Monad (MaybeT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • Monoid a => Monad (Tuple2 a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • ArrowApply a => Monad (ArrowMonad a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Arrow
  • Monad (t m) => Monad (LiftingAccum t m)Defined in mtl-2.3.1 · Control.Monad.Accum
  • Monad (t m) => Monad (LiftingSelect t m)Defined in mtl-2.3.1 · Control.Monad.Select
  • Monad f => Monad (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monad f => Monad (Alt f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monad f => Monad (Rec1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monad m => Monad (Kleisli m a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Arrow
  • Monad m => Monad (StateT s m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils
  • Monad m => Monad (ExceptT e m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • Monad m => Monad (IdentityT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • Monad m => Monad (ReaderT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Reader
  • Monad m => Monad (SelectT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Select
  • Monad m => Monad (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Lazy
  • Monad m => Monad (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Strict
  • Monad m => Monad (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.CPS
  • Monad m => Monad (Reverse m)Defined in transformers-0.6.1.1 · Data.Functor.Reverse

    Derived instance.

  • (Monoid a, Monoid b) => Monad (Tuple3 a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • (Monoid w, Functor m, Monad m) => Monad (AccumT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Accum
  • (Monoid w, Monad m) => Monad (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Monoid w, Monad m) => Monad (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • Monad (ContT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Cont
  • Monad ((->) r)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • (Monad f, Monad g) => Monad (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Monad f, Monad g) => Monad (f :*: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Monoid a, Monoid b, Monoid c) => Monad (Tuple4 a b c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monad f => Monad (M1 i c f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monad m => Monad (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.CPS
  • (Monoid w, Monad m) => Monad (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.Lazy
  • (Monoid w, Monad m) => Monad (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.Strict
classclass Functor f => Applicative (f :: Type -> Type) where
#

A functor with application, providing operations to

  • embed pure expressions (pure), and

  • sequence computations and combine their results (<*> and liftA2).

A minimal complete definition must include implementations of pure and of either <*> or liftA2. If it defines both, then they must behave the same as their default definitions:

(<*>) = liftA2 id
liftA2 f x y = f Prelude.<$> x <*> y

Further, any definition must satisfy the following:

Identity
pure id <*> v = v
Composition
pure (.) <*> u <*> v <*> w = u <*> (v <*> w)
Homomorphism
pure f <*> pure x = pure (f x)
Interchange
u <*> pure y = pure ($ y) <*> u

The other methods have the following default definitions, which may be overridden with equivalent specialized implementations:

As a consequence of these laws, the Functor instance for f will satisfy

It may be useful to note that supposing

forall x y. p (q x y) = f x . g y

it follows from the above that

liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v

If f is also a Monad, it should satisfy

(which implies that pure and <*> satisfy the applicative functor laws).

Methods

  • pure :: a -> f a

    Lift a value into the Structure.

    Examples
    Example1 expression
    pure 1 :: Maybe IntJust 1
    Example1 expression
    pure 'z' :: [Char]"z"
    Example1 expression
    pure (pure ":D") :: Maybe [String]Just [":D"]
  • (<*>) :: f (a -> b) -> f a -> f binfixl 4

    Sequential application.

    A few functors support an implementation of <*> that is more efficient than the default one.

    Example

    Used in combination with (Data.Functor.<$>), (<*>) can be used to build a record.

    Example1 expression
    data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
    Example3 expressions
    produceFoo :: Applicative f => f FooproduceBar :: Applicative f => f BarproduceBaz :: Applicative f => f Baz
    Example2 expressions
    mkState :: Applicative f => f MyStatemkState = MyState <$> produceFoo <*> produceBar <*> produceBaz
  • liftA2 :: (a -> b -> c) -> f a -> f b -> f c

    Lift a binary function to actions.

    Some functors support an implementation of liftA2 that is more efficient than the default one. In particular, if fmap is an expensive operation, it is likely better to use liftA2 than to fmap over the structure and then use <*>.

    This became a typeclass method in 4.10.0.0. Prior to that, it was a function defined in terms of <*> and fmap.

    Example
    Example1 expression
    liftA2 (,) (Just 3) (Just 5)Just (3,5)
    Example1 expression
    liftA2 (+) [1, 2, 3] [4, 5, 6][5,6,7,6,7,8,7,8,9]
  • (*>) :: f a -> f b -> f binfixl 4

    Sequence actions, discarding the value of the first argument.

    Examples

    If used in conjunction with the Applicative instance for Maybe, you can chain Maybe computations, with a possible "early return" in case of Nothing.

    Example1 expression
    Just 2 *> Just 3Just 3
    Example1 expression
    Nothing *> Just 3Nothing

    Of course a more interesting use case would be to have effectful computations instead of just returning pure values.

    Example4 expressions
    import Data.Charimport GHC.Internal.Text.ParserCombinators.ReadPlet p = string "my name is " *> munch1 isAlpha <* eofreadP_to_S p "my name is Simon"[("Simon","")]
  • (<*) :: f a -> f b -> f ainfixl 4

    Sequence actions, discarding the value of the second argument.

Instances77Applicative, …
classclass Semigroup a => Monoid a where
#

The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following:

Right identity

x <> mempty = x

Left identity

mempty <> x = x

Associativity

x <> (y <> z) = (x <> y) <> z

(

Semigroup

law)

Concatenation

mconcat = foldr (<>) mempty

You can alternatively define mconcat instead of mempty, in which case the laws are:

Unit

mconcat (pure x) = x

Multiplication

mconcat (join xss) = mconcat (fmap mconcat xss)

Subclass

mconcat (toList xs) = sconcat xs

The method names refer to the monoid of lists under concatenation, but there are many other instances.

Some types can be viewed as a monoid in more than one way, e.g. both addition and multiplication on numbers. In such cases we often define newtypes and make those instances of Monoid, e.g. Data.Semigroup.Sum and Data.Semigroup.Product.

NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.

Methods

  • mempty :: a

    Identity of mappend

    Examples
    Example1 expression
    "Hello world" <> mempty"Hello world"
    Example1 expression
    mempty <> [1, 2, 3][1,2,3]
  • mappend :: a -> a -> a

    An associative operation

    NOTE: This method is redundant and has the default implementation mappend = (<>) since base-4.11.0.0. Should it be implemented manually, since mappend is a synonym for (<>), it is expected that the two functions are defined the same way. In a future GHC release mappend will be removed from Monoid.

  • mconcat :: [a] -> a

    Fold a list using the monoid.

    For most types, the default definition for mconcat will be used, but the function is included in the class definition so that an optimized version can be provided for specific types.

    Example1 expression
    mconcat ["Hello", " ", "Haskell", "!"]"Hello Haskell!"
Instances70Monoid, …
  • Monoid ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • Monoid BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.Internal
  • Monoid ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Monoid ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • Monoid ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • Monoid AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Monoid EventLifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Monoid LifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types

    mappend takes the longer of two lifetimes.

  • Monoid ExceptionContextDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Context
  • Monoid OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid OsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types

    "String-Concatenation" for OsString. This is not the same as (</>).

  • Monoid PosixStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Monoid WindowsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Monoid DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJ
  • Monoid CalendarDiffDaysDefined in time-1.12.2 · Data.Time.Calendar.CalendarDiffDays

    Additive

  • Monoid CalendarDiffTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.CalendarDiffTime

    Additive

  • Monoid StatxFlagsDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Monoid StatxMaskDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Monoid ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid (Comparison a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    mempty on comparisons always returns EQ. Without newtypes this equals pure (pure EQ).

    mempty :: Comparison a
    mempty = Comparison _ _ -> EQ
    
  • Monoid (Equivalence a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    mempty on equivalences always returns True. Without newtypes this equals pure (pure True).

    mempty :: Equivalence a
    mempty = Equivalence _ _ -> True
    
  • Monoid (Predicate a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    mempty on predicates always returns True. Without newtypes this equals pure True.

    mempty :: Predicate a
    mempty = _ -> True
    
  • Monoid (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monoid (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monoid (Endo a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Monoid [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid a => Monoid (STM a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Monoid a => Monoid (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Monoid a => Monoid (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Monoid a => Monoid (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid a => Monoid (IO a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid a => Monoid (Q a)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Monoid a => Monoid (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid m => Monoid (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Monoid p => Monoid (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Semigroup a => Monoid (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base

    Lift a semigroup into Maybe forming a Monoid according to http://en.wikipedia.org/wiki/Monoid: "Any semigroup S may be turned into a monoid simply by adjoining an element e not in S and defining e*e = e and e*s = s = s*e for all s ∈ S."

    Since 4.11.0: constraint on inner a value generalised from Monoid to Semigroup.

  • Bits a => Monoid (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Bits a => Monoid (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • FiniteBits a => Monoid (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits

    This constraint is arguably too strong. However, as some types (such as Natural) have undefined complement, this is the only safe choice.

  • FiniteBits a => Monoid (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits

    This constraint is arguably too strong. However, as some types (such as Natural) have undefined complement, this is the only safe choice.

  • Num a => Monoid (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Num a => Monoid (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Ord a => Monoid (Max a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils
  • Ord a => Monoid (Min a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils
  • (Generic a, Monoid (Rep a ())) => Monoid (Generically a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Ord a, Bounded a) => Monoid (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • (Ord a, Bounded a) => Monoid (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Monoid (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Monoid (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monoid a => Monoid (Op a b)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    mempty @(Op a b) without newtypes is mempty @(b->a) = _ -> mempty.

    mempty :: Op a b
    mempty = Op _ -> mempty
    
  • Monoid a => Monoid (ST s a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ST
  • Monoid b => Monoid (a -> b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • (Monoid a, Monoid b) => Monoid (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Alternative f => Monoid (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid (f p) => Monoid (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monoid a => Monoid (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Monoid a => Monoid (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • (Applicative f, Monoid a) => Monoid (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • (Monoid a, Monoid b, Monoid c) => Monoid (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid c => Monoid (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Monoid (f a), Monoid (g a)) => Monoid (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Monoid (f p), Monoid (g p)) => Monoid ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid (f (g a)) => Monoid (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Monoid (f (g p)) => Monoid ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monoid (f p) => Monoid (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
typetype String = [Char]
#

String is an alias for a list of characters.

String constants in Haskell are values of type String. That means if you write a string literal like "hello world", it will have the type [Char], which is the same as String.

Note: You can ask the compiler to automatically infer different types with the -XOverloadedStrings language extension, for example "hello world" :: Text. See IsString for more information.

Because String is just a list of characters, you can use normal list functions to do basic string manipulation. See Data.List for operations on lists.

Performance considerations

[Char] is a relatively memory-inefficient type. It is a linked list of boxed word-size characters, internally it looks something like:

╭─────┬───┬──╮  ╭─────┬───┬──╮  ╭─────┬───┬──╮  ╭────╮
│ (:) │   │ ─┼─>│ (:) │   │ ─┼─>│ (:) │   │ ─┼─>│ [] │
╰─────┴─┼─┴──╯  ╰─────┴─┼─┴──╯  ╰─────┴─┼─┴──╯  ╰────╯
        v               v               v
       'a'             'b'             'c'

The String "abc" will use 5*3+1 = 16 (in general 5n+1) words of space in memory.

Furthermore, operations like (++) (string concatenation) are O(n) (in the left argument).

For historical reasons, the base library uses String in a lot of places for the conceptual simplicity, but library code dealing with user-data should use the text package for Unicode text, or the the bytestring package for binary data.

newtypenewtype IO a
#

A value of type IO a is a computation which, when performed, does some I/O before returning a value of type a.

There is really only one way to "perform" an I/O action: bind it to Main.main in your program. When your program is run, the I/O will be performed. It isn't possible to perform I/O from an arbitrary function, unless that function is itself in the IO monad and called at some point, directly or indirectly, from Main.main.

IO is a monad, so IO actions can be combined using either the do-notation or the Prelude.>> and Prelude.>>= operations from the Prelude.Monad class.

Instances39Monad, Functor, MonadFix, MonadFail, Applicative, GHCiSandboxIO, …
datadata Either a b
#

The Either type represents values with two possibilities: a value of type Either a b is either Left a or Right b.

The Either type is sometimes used to represent a value which is either correct or an error; by convention, the Left constructor is used to hold an error value and the Right constructor is used to hold a correct value (mnemonic: "right" also means "correct").

Examples

The type Either String Int is the type of values which can be either a String or an Int. The Left constructor can be used only on Strings, and the Right constructor can be used only on Ints:

Example6 expressions
let s = Left "foo" :: Either String IntsLeft "foo"let n = Right 3 :: Either String IntnRight 3:type ss :: Either String Int:type nn :: Either String Int

The fmap from our Functor instance will ignore Left values, but will apply the supplied function to values contained in a Right:

Example4 expressions
let s = Left "foo" :: Either String Intlet n = Right 3 :: Either String Intfmap (*2) sLeft "foo"fmap (*2) nRight 6

The Monad instance for Either allows us to chain together multiple actions which may fail, and fail overall if any of the individual steps failed. First we'll write a function that can either parse an Int from a Char, or fail.

Example3 expressions
import Data.Char ( digitToInt, isDigit ):{    let parseEither :: Char -> Either String Int        parseEither c          | isDigit c = Right (digitToInt c)          | otherwise = Left "parse error":}

The following should work, since both '1' and '2' can be parsed as Ints.

Example2 expressions
:{    let parseMultiple :: Either String Int        parseMultiple = do          x <- parseEither '1'          y <- parseEither '2'          return (x + y):}
Example1 expression
parseMultipleRight 3

But the following should fail overall, since the first operation where we attempt to parse 'm' as an Int will fail:

Example2 expressions
:{    let parseMultiple :: Either String Int        parseMultiple = do          x <- parseEither 'm'          y <- parseEither '2'          return (x + y):}
Example1 expression
parseMultipleLeft "parse error"

Constructors

Instances38Bifoldable, Bifoldable1, Bifunctor, Bitraversable, Eq2, Ord2, …
valueundefined :: HasCallStack => a
#

A special case of error. It is expected that compilers will recognize this and insert error messages which are more appropriate to the context in which undefined appears.

classclass (Real a, Enum a) => Integral a where
#

Integral numbers, supporting integer division.

The Haskell Report defines no laws for Integral. However, Integral instances are customarily expected to define a Euclidean domain and have the following properties for the div/mod and quot/rem pairs, given suitable Euclidean functions f and g:

  • x = y * quot x y + rem x y with rem x y = fromInteger 0 or g (rem x y) < g y

  • x = y * div x y + mod x y with mod x y = fromInteger 0 or f (mod x y) < f y

An example of a suitable Euclidean function, for Integer's instance, is abs.

In addition, toInteger should be total, and fromInteger should be a left inverse for it, i.e. fromInteger (toInteger i) = i.

Methods

  • quot :: a -> a -> ainfixl 7

    Integer division truncated toward zero.

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • rem :: a -> a -> ainfixl 7

    Integer remainder, satisfying

    (x `quot` y)*y + (x `rem` y) == x

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • div :: a -> a -> ainfixl 7

    Integer division truncated toward negative infinity.

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • mod :: a -> a -> ainfixl 7

    Integer modulus, satisfying

    (x `div` y)*y + (x `mod` y) == x

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • quotRem :: a -> a -> (a, a)

    Simultaneous quot and rem.

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • divMod :: a -> a -> (a, a)

    simultaneous div and mod.

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • toInteger :: a -> Integer

    Conversion to Integer.

Instances60Integral, …
  • Integral IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Integral WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Integral Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral StatxFlagsDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Integral StatxMaskDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Integral a => Integral (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Integral a => Integral (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Integral (f (g a)) => Integral (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
value($!) :: (a -> b) -> a -> b
#

Strict (call-by-value) application operator. It takes a function and an argument, evaluates the argument to weak head normal form (WHNF), then calls the function with that value.

valueasTypeOf :: a -> a -> a
#

asTypeOf is a type-restricted version of const. It is usually used as an infix operator, and its typing forces its first argument (which is usually overloaded) to have the same type as the second.

valueconst :: a -> b -> a
#

const x y always evaluates to x, ignoring its second argument.

const x = \_ -> x

This function might seem useless at first glance, but it can be very useful in a higher order context.

Examples
Example1 expression
const 42 "hello"42
Example1 expression
map (const 42) [0..3][42,42,42,42]
valueflip :: (a -> b -> c) -> b -> a -> c
#

flip f takes its (first) two arguments in the reverse order of f.

Property
flip f x y = f y x
Property
flip . flip = id
Examples
Example1 expression
flip (++) "hello" "world""worldhello"
Example1 expression
let (.>) = flip (.) in (+1) .> show $ 5"6"
valueid :: a -> a
#

Identity function.

id x = x

This function might seem useless at first glance, but it can be very useful in a higher order context.

Examples
Example1 expression
length $ filter id [True, True, False, True]3
Example1 expression
Just (Just 3) >>= idJust 3
Example1 expression
foldr id 0 [(^3), (*5), (+2)]1000
valueuntil :: (a -> Bool) -> (a -> a) -> a -> a
#

until p f yields the result of applying f until p holds.

value(&&) :: Bool -> Bool -> Bool
#

Boolean "and", lazy in the second argument

value(||) :: Bool -> Bool -> Bool
#

Boolean "or", lazy in the second argument

classclass Eq a => Ord a where
#

The Ord class is used for totally ordered datatypes.

Instances of Ord can be derived for any user-defined datatype whose constituent types are in Ord. The declared order of the constructors in the data declaration determines the ordering in derived Ord instances. The Ordering datatype allows a single comparison to determine the precise ordering of two objects.

Ord, as defined by the Haskell report, implements a total order and has the following properties:

Comparability

x <= y || y <= x

=

True

Transitivity

if

x <= y && y <= z

=

True

, then

x <= z

=

True

Reflexivity

x <= x

=

True

Antisymmetry

if

x <= y && y <= x

=

True

, then

x == y

=

True

The following operator interactions are expected to hold:

  1. x >= y = y <= x

  2. x < y = x <= y && x /= y

  3. x > y = y < x

  4. x < y = compare x y == LT

  5. x > y = compare x y == GT

  6. x == y = compare x y == EQ

  7. min x y == if x <= y then x else y = True

  8. max x y == if x >= y then x else y = True

Note that (7.) and (8.) do not require min and max to return either of their arguments. The result is merely required to equal one of the arguments in terms of (==).

Minimal complete definition: either compare or <=. Using compare can be more efficient for complex types.

Methods

Instances277Ord, …
  • Ord ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte

    Non-lexicographic ordering. This compares the lengths of the byte arrays first and uses a lexicographic ordering if the lengths are equal. Subject to change between major versions.

  • Ord ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Ord ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • Ord ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal

    Lexicographic order.

  • Ord BigNatDefined in ghc-bignum-1.3 · GHC.Num.BigNat
  • Ord IntegerDefined in ghc-bignum-1.3 · GHC.Num.Integer
  • Ord NaturalDefined in ghc-bignum-1.3 · GHC.Num.Natural
  • Ord ExtensionDefined in ghc-boot-th-9.10.3 · GHC.LanguageExtensions.Type
  • Ord VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Ord ByteOrderDefined in ghc-internal-9.1003.0 · GHC.Internal.ByteOrder
  • Ord ClosureTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.ClosureTypes
  • Ord BlockReasonDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Ord ThreadIdDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Ord ThreadStatusDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Ord AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Ord AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Ord SomeTypeRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Typeable.Internal
  • Ord UniqueDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Unique
  • Ord VersionDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Version
  • Ord TimeoutKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.TimeOut
  • Ord UniqueDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Unique
  • Ord ErrorCallDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception
  • Ord ArithExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Type
  • Ord FingerprintDefined in ghc-internal-9.1003.0 · GHC.Internal.Fingerprint.Type
  • Ord CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ord IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Ord WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Ord AssociativityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord DecidedStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord SourceStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord SourceUnpackednessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Ord ArrayExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Ord AsyncExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Ord ExitCodeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Ord BufferModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Ord NewlineDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Ord NewlineModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Ord IOModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.IOMode
  • Ord Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ord Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ord Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ord Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ord CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CTimerDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ord SomeCharDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Ord SomeSymbolDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Ord SomeNatDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • Ord GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.Unicode
  • Ord Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ord Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ord Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ord Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ord BoolDefined in ghc-prim-0.12.0 · GHC.Classes
  • Ord CharDefined in ghc-prim-0.12.0 · GHC.Classes
  • Ord DoubleDefined in ghc-prim-0.12.0 · GHC.Classes

    IEEE 754 Double-precision type includes not only numbers, but also positive and negative infinities and a special element called NaN (which can be quiet or signal).

    IEEE 754-2008, section 5.11 requires that if at least one of arguments of <=, <, >, >= is NaN then the result of the comparison is False, and instance Ord Double complies with this requirement. This violates the reflexivity: both NaN <= NaN and NaN >= NaN are False.

    IEEE 754-2008, section 5.10 defines totalOrder predicate. Unfortunately, compare on Doubles violates the IEEE standard and does not define a total order. More specifically, both compare NaN x and compare x NaN always return GT.

    Thus, users must be extremely cautious when using instance Ord Double. For instance, one should avoid ordered containers with keys represented by Double, because data loss and corruption may happen. An IEEE-compliant compare is available in fp-ieee package as TotallyOrdered newtype.

    Moving further, the behaviour of min and max with regards to NaN is also non-compliant. IEEE 754-2008, section 5.3.1 defines that quiet NaN should be treated as a missing data by minNum and maxNum functions, for example, minNum(NaN, 1) = minNum(1, NaN) = 1. Some languages such as Java deviate from the standard implementing minNum(NaN, 1) = minNum(1, NaN) = NaN. However, min / max in base are even worse: min NaN 1 is 1, but min 1 NaN is NaN.

    IEEE 754-2008 compliant min / max can be found in ieee754 package under minNum / maxNum names. Implementations compliant with minimumNumber / maximumNumber from a newer IEEE 754-2019, section 9.6 are available from fp-ieee package.

  • Ord FloatDefined in ghc-prim-0.12.0 · GHC.Classes

    See instance Ord Double for discussion of deviations from IEEE 754 standard.

  • Ord IntDefined in ghc-prim-0.12.0 · GHC.Classes
  • Ord OrderingDefined in ghc-prim-0.12.0 · GHC.Classes
  • Ord TyConDefined in ghc-prim-0.12.0 · GHC.Classes
  • Ord WordDefined in ghc-prim-0.12.0 · GHC.Classes
  • Ord OsCharDefined in os-string-2.0.7 · System.OsString.Internal.Types

    Byte ordering of the internal representation.

  • Ord OsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types

    Byte ordering of the internal representation.

  • Ord PosixCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Ord PosixStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Ord WindowsCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Ord WindowsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Ord PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Ord PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Ord AnnLookupDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord AnnTargetDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord BangDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord BndrVisDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord BodyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord BytesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord CallconvDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord ClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord ConDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord DecDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord DecidedStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord DerivClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord DerivStrategyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord DocLocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord ExpDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord FamilyResultSigDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord FixityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord FixityDirectionDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord ForeignDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord FunDepDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord GuardDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord InfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord InjectivityAnnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord InlineDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord LitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord LocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord MatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord ModNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord ModuleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord ModuleInfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord NameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord NameFlavourDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord NameSpaceDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord NamespaceSpecifierDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord OccNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord OverlapDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord PatDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord PatSynArgsDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord PatSynDirDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord PhasesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord PkgNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord PragmaDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord RangeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord RoleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord RuleBndrDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord RuleMatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord SafetyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord SourceStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord SourceUnpackednessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord SpecificityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord StmtDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord TyLitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord TySynEqnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord TypeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord TypeFamilyHeadDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • Ord MonthDefined in time-1.12.2 · Data.Time.Calendar.Month
  • Ord QuarterDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Ord QuarterOfYearDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Ord DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Ord AbsoluteTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.AbsoluteTime
  • Ord DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Ord NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Ord SystemTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.SystemTime
  • Ord UTCTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UTCTime
  • Ord UniversalTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UniversalTime
  • Ord TimeLocaleDefined in time-1.12.2 · Data.Time.Format.Locale
  • Ord LocalTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.LocalTime
  • Ord TimeOfDayDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeOfDay
  • Ord TimeZoneDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeZone
  • Ord DirTypeDefined in unix-2.8.7.0 · System.Posix.Directory.Common
  • Ord CAttributesDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Ord StatxFlagsDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Ord StatxMaskDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Ord OpenFileFlagsDefined in unix-2.8.7.0 · System.Posix.IO.Common
  • Ord OpenModeDefined in unix-2.8.7.0 · System.Posix.IO.Common
  • Ord ProcessStatusDefined in unix-2.8.7.0 · System.Posix.Process.Internals
  • Ord BaudRateDefined in unix-2.8.7.0 · System.Posix.Terminal.Common
  • Ord ()Defined in ghc-prim-0.12.0 · GHC.Classes
  • Integral a => Ord (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Ord (ConstPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.ConstPtr
  • Ord (ForeignPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ForeignPtr
  • Ord (FunPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Ord (Ptr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Ord (SChar c)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Ord (SSymbol s)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Ord (SNat n)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • Ord a => Ord (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Ord a => Ord (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Ord a => Ord (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Ord a => Ord (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Ord a => Ord (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Ord a => Ord (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Ord a => Ord (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Ord a => Ord (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Ord a => Ord (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Ord a => Ord (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Ord a => Ord (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Ord a => Ord (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Ord a => Ord (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList
  • Ord a => Ord (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Maybe
  • Ord a => Ord (a)Defined in ghc-prim-0.12.0 · GHC.Classes
  • Ord a => Ord [a]Defined in ghc-prim-0.12.0 · GHC.Classes
  • Ord flag => Ord (TyVarBndr flag)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord m => Ord (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Ord p => Ord (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Ord (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Ord (TypeRep a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Typeable.Internal
  • Ord (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord a => Ord (Arg a b)Defined in base-4.20.2.0 · Data.Semigroup
  • (Ord1 f, Ord a) => Ord (Lift f a)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • (Ord1 m, Ord a) => Ord (MaybeT m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • (Ix i, Ord e) => Ord (Array i e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Arr
  • (Ix ix, Ord e, IArray UArray e) => Ord (UArray ix e)Defined in array-0.5.8.0 · Data.Array.Base
  • (Ord a, Ord b) => Ord (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either
  • (Ord a, Ord b) => Ord (a, b)Defined in ghc-prim-0.12.0 · GHC.Classes
  • Ord (Coercion a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • Ord (URec Char p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (URec Int p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (URec Word p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (URec (Ptr ()) p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Ord (f a) => Ord (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Ord (f a) => Ord (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Ord (f p) => Ord (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord a => Ord (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Ord a => Ord (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • (Ord1 f, Ord a) => Ord (Backwards f a)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • (Ord1 f, Ord a) => Ord (IdentityT f a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • (Ord1 f, Ord a) => Ord (Reverse f a)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • (Generic1 f, Ord (Rep1 f a)) => Ord (Generically1 f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Ord a, Ord b, Ord c) => Ord (a, b, c)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Ord e, Ord1 m, Ord a) => Ord (ExceptT e m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • (Ord w, Ord1 m, Ord a) => Ord (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Ord w, Ord1 m, Ord a) => Ord (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • Ord (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Ord c => Ord (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Ord (f a), Ord (g a)) => Ord (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Ord (f a), Ord (g a)) => Ord (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Ord (f p), Ord (g p)) => Ord ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Ord (f p), Ord (g p)) => Ord ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Ord a, Ord b, Ord c, Ord d) => Ord (a, b, c, d)Defined in ghc-prim-0.12.0 · GHC.Classes
  • Ord (f (g a)) => Ord (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Ord (f (g p)) => Ord ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (f p) => Ord (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Ord a, Ord b, Ord c, Ord d, Ord e) => Ord (a, b, c, d, e)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f) => Ord (a, b, c, d, e, f)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g) => Ord (a, b, c, d, e, f, g)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h) => Ord (a, b, c, d, e, f, g, h)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i) => Ord (a, b, c, d, e, f, g, h, i)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j) => Ord (a, b, c, d, e, f, g, h, i, j)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k) => Ord (a, b, c, d, e, f, g, h, i, j, k)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l) => Ord (a, b, c, d, e, f, g, h, i, j, k, l)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n, Ord o) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)Defined in ghc-prim-0.12.0 · GHC.Classes
valuerealToFrac :: (Real a, Fractional b) => a -> b
#

General coercion to Fractional types.

WARNING: This function goes through the Rational type, which does not have values for NaN for example. This means it does not round-trip.

For Double it also behaves differently with or without -O0:

Prelude> realToFrac nan -- With -O0
-Infinity
Prelude> realToFrac nan
NaN
valuefromIntegral :: (Integral a, Num b) => a -> b
#

General coercion from Integral types.

WARNING: This function performs silent truncation if the result type is not at least as big as the argument's type.

classclass (Num a, Ord a) => Real a where
#

Real numbers.

The Haskell report defines no laws for Real, however Real instances are customarily expected to adhere to the following law:

Coherence with fromRational

if the type also implements

Fractional

, then

fromRational

is a left inverse for

toRational

, i.e.

fromRational (toRational i) = i

The law does not hold for Float, Double, CFloat, CDouble, etc., because these types contain non-finite values, which cannot be roundtripped through Rational.

Methods

Instances76Real, …
  • Real IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Real WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Real Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Real Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Real Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Real Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Real DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that toRational generates garbage for non-finite arguments:

    Example2 expressions
    toRational (1/0)179769313 (and 300 more digits...) % 1toRational (0/0)269653970 (and 300 more digits...) % 1
  • Real FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that toRational generates garbage for non-finite arguments:

    Example2 expressions
    toRational (1/0 :: Float)340282366920938463463374607431768211456 % 1toRational (0/0 :: Float)510423550381407695195061911147652317184 % 1
  • Real IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Real NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Real StatxFlagsDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Real StatxMaskDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Real BaudRateDefined in unix-2.8.7.0 · System.Posix.Terminal.Common
  • Integral a => Real (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real a => Real (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Real a => Real (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • HasResolution a => Real (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Real a => Real (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Real (f (g a)) => Real (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
classclass Num a => Fractional a where
#

Fractional numbers, supporting real division.

The Haskell Report defines no laws for Fractional. However, (+) and (*) are customarily expected to define a division ring and have the following properties:

recip gives the multiplicative inverse

x * recip x

=

recip x * x

=

fromInteger 1

Totality of toRational

toRational

is total

Coherence with toRational

if the type also implements

Real

, then

fromRational

is a left inverse for

toRational

, i.e.

fromRational (toRational i) = i

Note that it isn't customarily expected that a type instance of Fractional implement a field. However, all instances in base do.

Methods

Instances14Fractional, …
  • Fractional CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Fractional CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Fractional DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero.

    Example4 expressions
    0 == (-0 :: Double)Truerecip 0 == recip (-0 :: Double)Falsemap (/ 0) [-1, 0, 1][-Infinity,NaN,Infinity]map (* 0) $ map (/ 0) [-1, 0, 1][NaN,NaN,NaN]
  • Fractional FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero.

    Example4 expressions
    0 == (-0 :: Float)Truerecip 0 == recip (-0 :: Float)Falsemap (/ 0) [-1, 0, 1 :: Float][-Infinity,NaN,Infinity]map (* 0) $ map (/ 0) [-1, 0, 1 :: Float][NaN,NaN,NaN]
  • Fractional DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Fractional NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • RealFloat a => Fractional (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Fractional a => Fractional (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Fractional a => Fractional (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Integral a => Fractional (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • HasResolution a => Fractional (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Fractional a => Fractional (Op a b)Defined in base-4.20.2.0 · Data.Functor.Contravariant
  • Fractional a => Fractional (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Fractional (f (g a)) => Fractional (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
typetype Rational = Ratio Integer
#

Arbitrary-precision rational numbers, represented as a ratio of two Integer values. A rational number may be constructed using the % operator.

classclass (Real a, Fractional a) => RealFrac a where
#

Extracting components of fractions.

Methods

Instances12RealFrac, …
  • RealFrac CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • RealFrac CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • RealFrac DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that results for non-finite arguments are garbage:

    Example2 expressions
    [ f x | f <- [round, floor, ceiling], x <- [-1/0, 0/0, 1/0] ] :: [Int][0,0,0,0,0,0,0,0,0]map properFraction [-1/0, 0/0, 1/0] :: [(Int, Double)][(0,0.0),(0,0.0),(0,0.0)]

    and get even more non-sensical if you ask for Integer instead of Int.

  • RealFrac FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that results for non-finite arguments are garbage:

    Example2 expressions
    [ f x | f <- [round, floor, ceiling], x <- [-1/0, 0/0, 1/0 :: Float] ] :: [Int][0,0,0,0,0,0,0,0,0]map properFraction [-1/0, 0/0, 1/0] :: [(Int, Float)][(0,0.0),(0,0.0),(0,0.0)]

    and get even more non-sensical if you ask for Integer instead of Int.

  • RealFrac DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • RealFrac NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Integral a => RealFrac (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • RealFrac a => RealFrac (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • RealFrac a => RealFrac (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • HasResolution a => RealFrac (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • RealFrac a => RealFrac (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • RealFrac (f (g a)) => RealFrac (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
classclass Enum a where
#

Class Enum defines operations on sequentially ordered types.

The enumFrom... methods are used in Haskell's translation of arithmetic sequences.

Instances of Enum may be derived for any enumeration type (types whose constructors have no fields). The nullary constructors are assumed to be numbered left-to-right by fromEnum from 0 through n-1. See Chapter 10 of the Haskell Report for more details.

For any type that is an instance of class Bounded as well as Enum, the following should hold:

   enumFrom     x   = enumFromTo     x maxBound
   enumFromThen x y = enumFromThenTo x y bound
     where
       bound | fromEnum y >= fromEnum x = maxBound
             | otherwise                = minBound

Methods

  • succ :: a -> a

    Successor of a value. For numeric types, succ adds 1.

  • pred :: a -> a

    Predecessor of a value. For numeric types, pred subtracts 1.

  • toEnum :: Int -> a

    Convert from an Int.

  • fromEnum :: a -> Int

    Convert to an Int. It is implementation-dependent what fromEnum returns when applied to a value that is too large to fit in an Int.

  • enumFrom :: a -> [a]

    Used in Haskell's translation of [n..] with [n..] = enumFrom n, a possible implementation being enumFrom n = n : enumFrom (succ n).

    Examples
    • enumFrom 4 :: [Integer] = [4,5,6,7,...]
    • enumFrom 6 :: [Int] = [6,7,8,9,...,maxBound :: Int]
  • enumFromThen :: a -> a -> [a]

    Used in Haskell's translation of [n,n'..] with [n,n'..] = enumFromThen n n', a possible implementation being enumFromThen n n' = n : n' : worker (f x) (f x n'), worker s v = v : worker s (s v), x = fromEnum n' - fromEnum n and

      f n y
        | n > 0 = f (n - 1) (succ y)
        | n < 0 = f (n + 1) (pred y)
        | otherwise = y
      
    Examples
    • enumFromThen 4 6 :: [Integer] = [4,6,8,10...]
    • enumFromThen 6 2 :: [Int] = [6,2,-2,-6,...,minBound :: Int]
  • enumFromTo :: a -> a -> [a]

    Used in Haskell's translation of [n..m] with [n..m] = enumFromTo n m, a possible implementation being

      enumFromTo n m
         | n <= m = n : enumFromTo (succ n) m
         | otherwise = []
      
    Examples
    • enumFromTo 6 10 :: [Int] = [6,7,8,9,10]
    • enumFromTo 42 1 :: [Integer] = []
  • enumFromThenTo :: a -> a -> a -> [a]

    Used in Haskell's translation of [n,n'..m] with [n,n'..m] = enumFromThenTo n n' m, a possible implementation being enumFromThenTo n n' m = worker (f x) (c x) n m, x = fromEnum n' - fromEnum n, c x = bool (>=) ((x 0)

      f n y
         | n > 0 = f (n - 1) (succ y)
         | n < 0 = f (n + 1) (pred y)
         | otherwise = y
      

    and

      worker s c v m
         | c v m = v : worker s c (s v) m
         | otherwise = []
      
    Examples
    • enumFromThenTo 4 2 -6 :: [Integer] = [4,2,0,-2,-4,-6]
    • enumFromThenTo 6 8 2 :: [Int] = []
Instances119Enum, …
  • Enum IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum ExtensionDefined in ghc-boot-th-9.10.3 · GHC.LanguageExtensions.Type
  • Enum ByteOrderDefined in ghc-internal-9.1003.0 · GHC.Internal.ByteOrder
  • Enum ClosureTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.ClosureTypes
  • Enum CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Enum WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Enum AssociativityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Enum DecidedStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Enum SourceStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Enum SourceUnpackednessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Enum SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Enum IOModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.IOMode
  • Enum Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Enum Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Enum Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Enum Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Enum DoCostCentresDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Enum DoHeapProfileDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Enum DoTraceDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Enum GiveGCStatsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Enum IoSubSystemDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Enum CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.Unicode
  • Enum Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Enum Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Enum Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Enum Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Enum BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum CharDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    fromEnum just truncates its argument, beware of all sorts of overflows.

    List generators have extremely peculiar behavior, mandated by Haskell Report 2010:

    Example1 expression
    [0..1.5][0.0,1.0,2.0]
  • Enum FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    fromEnum just truncates its argument, beware of all sorts of overflows.

    List generators have extremely peculiar behavior, mandated by Haskell Report 2010:

    Example1 expression
    [0..1.5 :: Float][0.0,1.0,2.0]
  • Enum IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum LevityDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum VecCountDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum VecElemDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • Enum MonthDefined in time-1.12.2 · Data.Time.Calendar.Month
  • Enum QuarterDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Enum QuarterOfYearDefined in time-1.12.2 · Data.Time.Calendar.Quarter

    maps Q1..Q4 to 1..4

  • Enum DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week

    "Circular", so for example [Tuesday ..] gives an endless sequence. Also: fromEnum gives [1 .. 7] for [Monday .. Sunday], and toEnum performs mod 7 to give a cycle of days.

  • Enum DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Enum NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Enum StatxFlagsDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Enum StatxMaskDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Enum BaudRateDefined in unix-2.8.7.0 · System.Posix.Terminal.Common
  • Enum ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum a => Enum (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Enum a => Enum (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Enum a => Enum (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Enum a => Enum (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Enum a => Enum (WrappedMonoid a)Defined in base-4.20.2.0 · Data.Semigroup
  • Enum a => Enum (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Enum a => Enum (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Enum a => Enum (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Enum a => Enum (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Enum a => Enum (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Enum a => Enum (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Integral a => Enum (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • (Enum a, Bounded a, Eq a) => Enum (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord

    Swaps succ and pred of the underlying type.

  • Enum (Fixed a)Defined in base-4.20.2.0 · Data.Fixed

    Recall that, for numeric types, succ and pred typically add and subtract 1, respectively. This is not true in the case of Fixed, whose successor and predecessor functions intuitively return the "next" and "previous" values in the enumeration. The results of these functions thus depend on the resolution of the Fixed value. For example, when enumerating values of resolution 10^-3 of type Milli = Fixed E3,

    Example1 expression
    succ (0.000 :: Milli)0.001

    and likewise

    Example1 expression
    pred (0.000 :: Milli)-0.001

    In other words, succ and pred increment and decrement a fixed-precision value by the least amount such that the value's resolution is unchanged. For example, 10^-12 is the smallest (positive) amount that can be added to a value of type Pico = Fixed E12 without changing its resolution, and so

    Example1 expression
    succ (0.000000000000 :: Pico)0.000000000001

    and similarly

    Example1 expression
    pred (0.000000000000 :: Pico)-0.000000000001

    This is worth bearing in mind when defining Fixed arithmetic sequences. In particular, you may be forgiven for thinking the sequence

      [1..10] :: [Pico]
    

    evaluates to [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] :: [Pico].

    However, this is not true. On the contrary, similarly to the above implementations of succ and pred, enumFromTo :: Pico -> Pico -> [Pico] has a "step size" of 10^-12. Hence, the list [1..10] :: [Pico] has the form

      [1.000000000000, 1.00000000001, 1.00000000002, ..., 10.000000000000]
    

    and contains 9 * 10^12 + 1 values.

  • Enum (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Enum (f a) => Enum (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Enum (f a) => Enum (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Enum a => Enum (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Coercible a b => Enum (Coercion a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • a ~ b => Enum (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • a ~~ b => Enum (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Enum (f (g a)) => Enum (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
valueall :: Foldable t => (a -> Bool) -> t a -> Bool
#

Determines whether all elements of the structure satisfy the predicate.

Examples

Basic usage:

Example1 expression
all (> 3) []True
Example1 expression
all (> 3) [1,2]False
Example1 expression
all (> 3) [1,2,3,4,5]False
Example1 expression
all (> 3) [1..]False
Example1 expression
all (> 3) [4..]* Hangs forever *
valuereplicate :: Int -> a -> [a]
#

replicate n x is a list of length n with x the value of every element. It is an instance of the more general genericReplicate, in which n may be of any integral type.

Examples
Example1 expression
replicate 0 True[]
Example1 expression
replicate (-1) True[]
Example1 expression
replicate 4 True[True,True,True,True]
value(^) :: (Num a, Integral b) => a -> b -> a
#

raise a number to a non-negative integral power

classclass Show a where
#

Conversion of values to readable Strings.

Derived instances of Show have the following properties, which are compatible with derived instances of Text.Read.Read:

  • The result of show is a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. It contains only the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used.

  • If the constructor is defined to be an infix operator, then showsPrec will produce infix applications of the constructor.

  • the representation will be enclosed in parentheses if the precedence of the top-level constructor in x is less than d (associativity is ignored). Thus, if d is 0 then the result is never surrounded in parentheses; if d is 11 it is always surrounded in parentheses, unless it is an atomic expression.

  • If the constructor is defined using record syntax, then show will produce the record-syntax form, with the fields given in the same order as the original declaration.

For example, given the declarations

infixr 5 :^:
data Tree a =  Leaf a  |  Tree a :^: Tree a

the derived instance of Show is equivalent to

instance (Show a) => Show (Tree a) where

       showsPrec d (Leaf m) = showParen (d > app_prec) $
            showString "Leaf " . showsPrec (app_prec+1) m
         where app_prec = 10

       showsPrec d (u :^: v) = showParen (d > up_prec) $
            showsPrec (up_prec+1) u .
            showString " :^: "      .
            showsPrec (up_prec+1) v
         where up_prec = 5

Note that right-associativity of :^: is ignored. For example,

  • show (Leaf 1 :^: Leaf 2 :^: Leaf 3) produces the string "Leaf 1 :^: (Leaf 2 :^: Leaf 3)".

Methods

  • showsPrec :: Int -> a -> ShowS

    Convert a value to a readable String.

    showsPrec should satisfy the law

    showsPrec d x r ++ s  ==  showsPrec d x (r ++ s)

    Derived instances of Text.Read.Read and Show satisfy the following:

    That is, readsPrec parses the string produced by showsPrec, and delivers the value that showsPrec started with.

  • show :: a -> String

    A specialised variant of showsPrec, using precedence context zero, and returning an ordinary String.

  • showList :: [a] -> ShowS

    The method showList is provided to allow the programmer to give a specialised way of showing lists of values. For example, this is used by the predefined Show instance of the Char type, where values of type String should be shown in double quotes, rather than between square brackets.

Instances393Show, …
  • Show ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • Show TimeoutDefined in base-4.20.2.0 · System.Timeout
  • Show BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder · orphan
  • Show FormatModeDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.RealFloat
  • Show FloatingDecimalDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.RealFloat.D2S
  • Show FloatingDecimalDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.RealFloat.F2S
  • Show ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Show SizeOverflowExceptionDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Show ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • Show ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • Show IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show ForeignSrcLangDefined in ghc-boot-th-9.10.3 · GHC.ForeignSrcLang.Type
  • Show ExtensionDefined in ghc-boot-th-9.10.3 · GHC.LanguageExtensions.Type
  • Show VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show ByteOrderDefined in ghc-internal-9.1003.0 · GHC.Internal.ByteOrder
  • Show ClosureTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.ClosureTypes
  • Show BlockReasonDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Show ThreadIdDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Show ThreadStatusDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Show NestedAtomicallyDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show NoMatchingContinuationPromptDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show NoMethodErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show NonTerminationDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show PatternMatchFailDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show RecConErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show RecSelErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show RecUpdErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show TypeErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show ConstrDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Show ConstrRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Show DataRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Show DataTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Show FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Show DynamicDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Dynamic
  • Show AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show SomeTypeRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Typeable.Internal
  • Show VersionDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Version
  • Show ControlMessageDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Control
  • Show EPollFdDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.EPoll
  • Show EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.EPoll
  • Show EventTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.EPoll
  • Show EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Show EventLifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Show LifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Show TimeoutDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Show FdKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Manager
  • Show StateDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Manager
  • Show EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Poll
  • Show PollFdDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Poll
  • Show StateDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.TimerManager
  • Show UniqueDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Unique
  • Show ErrorCallDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception
  • Show ArithExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Type
  • Show SomeExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Type
  • Show FingerprintDefined in ghc-internal-9.1003.0 · GHC.Internal.Fingerprint.Type
  • Show CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Show WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Show AssociativityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show DecidedStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show SourceStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show SourceUnpackednessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show MaskingStateDefined in ghc-internal-9.1003.0 · GHC.Internal.IO
  • Show SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Show CodingFailureModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Encoding.Failure
  • Show CodingProgressDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Encoding.Types
  • Show TextEncodingDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Encoding.Types
  • Show AllocationLimitExceededDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show ArrayExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show AssertionFailedDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show AsyncExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show BlockedIndefinitelyOnMVarDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show BlockedIndefinitelyOnSTMDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show CompactionFailedDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show DeadlockDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show ExitCodeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show FixIOExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show IOErrorTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show IOExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show SomeAsyncExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show FDDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.FD
  • Show HandlePosnDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle
  • Show FileLockingNotSupportedDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Lock.Common
  • Show BufferModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Show HandleDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Show HandleTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Show NewlineDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Show NewlineModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Show IOModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.IOMode
  • Show IOPortExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IOPort
  • Show InfoProvDefined in ghc-internal-9.1003.0 · GHC.Internal.InfoProv.Types
  • Show Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Show Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Show Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Show Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Show CCFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show ConcFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show DebugFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show DoCostCentresDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show DoHeapProfileDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show DoTraceDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show GCFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show GiveGCStatsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show HpcFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show IoSubSystemDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show MiscFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show ParFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show ProfFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show RTSFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show TickyFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show TraceFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show FractionalExponentBaseDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Show StackEntryDefined in ghc-internal-9.1003.0 · GHC.Internal.Stack.CloneStack
  • Show CallStackDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show SrcLocDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show StaticPtrInfoDefined in ghc-internal-9.1003.0 · GHC.Internal.StaticPtr
  • Show GCDetailsDefined in ghc-internal-9.1003.0 · GHC.Internal.Stats
  • Show RTSStatsDefined in ghc-internal-9.1003.0 · GHC.Internal.Stats
  • Show CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CTimerDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show LexemeDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.Read.Lex
  • Show NumberDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.Read.Lex
  • Show SomeCharDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Show SomeSymbolDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Show SomeNatDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • Show GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.Unicode
  • Show Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Show Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Show Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Show Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Show BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show CharDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan
  • Show FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan
  • Show IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show KindRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show LevityDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show ModuleDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show RuntimeRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show TrNameDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show TyConDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show TypeLitSortDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show VecCountDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show VecElemDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show EncodingExceptionDefined in os-string-2.0.7 · System.OsString.Encoding.Internal
  • Show OsCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Show OsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types

    On windows, decodes as UCS-2. On unix prints the raw bytes without decoding.

  • Show PosixCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Show PosixStringDefined in os-string-2.0.7 · System.OsString.Internal.Types

    Prints the raw bytes without decoding.

  • Show WindowsCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Show WindowsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types

    Decodes as UCS-2.

  • Show ModeDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show StyleDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show TextDetailsDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Show DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJ
  • Show PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Show ForallVisFlagDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Ppr
  • Show DocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.PprLib
  • Show AnnLookupDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show AnnTargetDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show BangDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show BndrVisDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show BodyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show BytesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show CallconvDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ConDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DecDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DecidedStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DerivClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DerivStrategyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DocLocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ExpDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show FamilyResultSigDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show FixityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show FixityDirectionDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ForeignDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show FunDepDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show GuardDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show InfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show InjectivityAnnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show InlineDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show LitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show LocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show MatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ModNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ModuleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ModuleInfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show NameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show NameFlavourDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show NameSpaceDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show NamespaceSpecifierDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show OccNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show OverlapDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PatDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PatSynArgsDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PatSynDirDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PhasesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PkgNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PragmaDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show RangeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show RoleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show RuleBndrDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show RuleMatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show SafetyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show SourceStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show SourceUnpackednessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show SpecificityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show StmtDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show TyLitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show TySynEqnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show TypeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show TypeFamilyHeadDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show CalendarDiffDaysDefined in time-1.12.2 · Data.Time.Calendar.CalendarDiffDays
  • Show DayDefined in time-1.12.2 · Data.Time.Calendar.Gregorian · orphan
  • Show MonthDefined in time-1.12.2 · Data.Time.Calendar.Month

    Show as yyyy-mm.

  • Show QuarterDefined in time-1.12.2 · Data.Time.Calendar.Quarter

    Show as yyyy-Qn.

  • Show QuarterOfYearDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Show DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Show AbsoluteTimeDefined in time-1.12.2 · Data.Time.Clock.TAI · orphan
  • Show DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Show NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Show SystemTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.SystemTime
  • Show UTCTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.ZonedTime · orphan
  • Show UniversalTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.LocalTime · orphan
  • Show TimeLocaleDefined in time-1.12.2 · Data.Time.Format.Locale
  • Show CalendarDiffTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.CalendarDiffTime
  • Show LocalTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.LocalTime
  • Show TimeOfDayDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeOfDay
  • Show TimeZoneDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeZone

    This only shows the time zone name, or offset if the name is empty.

  • Show ZonedTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.ZonedTime

    For the time zone, this only shows the name, or offset if the name is empty.

  • Show DirTypeDefined in unix-2.8.7.0 · System.Posix.Directory.Common
  • Show DLDefined in unix-2.8.7.0 · System.Posix.DynamicLinker.Prim
  • Show RTLDFlagsDefined in unix-2.8.7.0 · System.Posix.DynamicLinker.Prim
  • Show CAttributesDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Show StatxFlagsDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Show StatxMaskDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Show OpenFileFlagsDefined in unix-2.8.7.0 · System.Posix.IO.Common
  • Show OpenModeDefined in unix-2.8.7.0 · System.Posix.IO.Common
  • Show ProcessStatusDefined in unix-2.8.7.0 · System.Posix.Process.Internals
  • Show ResourceDefined in unix-2.8.7.0 · System.Posix.Resource
  • Show ResourceLimitDefined in unix-2.8.7.0 · System.Posix.Resource
  • Show ResourceLimitsDefined in unix-2.8.7.0 · System.Posix.Resource
  • Show BaudRateDefined in unix-2.8.7.0 · System.Posix.Terminal.Common
  • Show GroupEntryDefined in unix-2.8.7.0 · System.Posix.User.Common
  • Show UserEntryDefined in unix-2.8.7.0 · System.Posix.User.Common
  • Show ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show (ConstPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.ConstPtr
  • Show (ForeignPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ForeignPtr
  • Show (FunPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Show (Ptr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Show (SChar c)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Show (SSymbol s)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Show (SNat n)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • Show (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show a => Show (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Show a => Show (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Show a => Show (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Show a => Show (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Show a => Show (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Show a => Show (ExitCase a)Defined in exceptions-0.10.9 · Control.Monad.Catch
  • Show a => Show (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show a => Show (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity

    This instance would be equivalent to the derived instances of the Identity newtype if the runIdentity field were removed

  • Show a => Show (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Show a => Show (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Show a => Show (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord

    This instance would be equivalent to the derived instances of the Down newtype if the getDown field were removed

  • Show a => Show (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show a => Show (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show a => Show (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show a => Show (ExceptionWithContext a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Type
  • Show a => Show (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList
  • Show a => Show (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show a => Show (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Show a => Show (AnnotDetails a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show a => Show (Span a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show a => Show (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show a => Show [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show e => Show (NoBacktrace e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Type
  • Show flag => Show (TyVarBndr flag)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show m => Show (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Show p => Show (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • HasResolution a => Show (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Show (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Show (TypeRep a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Typeable.Internal
  • Show (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (ST s a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ST
  • Show (a -> b)Defined in base-4.20.2.0 · Text.Show.Functions · orphan
  • (Show1 f, Show a) => Show (Lift f a)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • (Show1 m, Show a) => Show (MaybeT m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • (Ix a, Show a, Show b) => Show (Array a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Arr
  • (Ix ix, Show ix, Show e, IArray UArray e) => Show (UArray ix e)Defined in array-0.5.8.0 · Data.Array.Base
  • (Show a, Show b) => Show (Arg a b)Defined in base-4.20.2.0 · Data.Semigroup
  • (Show a, Show b) => Show (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either
  • (Show a, Show b) => Show (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show (Coercion a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • Show (OrderingI a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Ord
  • Show (URec Char p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (URec Int p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (URec Word p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Show (f a) => Show (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Show (f a) => Show (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show (f p) => Show (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show a => Show (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const

    This instance would be equivalent to the derived instances of the Const newtype if the getConst field were removed

  • Show a => Show (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • (Show1 f, Show a) => Show (Backwards f a)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • (Show1 f, Show a) => Show (IdentityT f a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • (Show1 f, Show a) => Show (Reverse f a)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • (Show a, Show b, Show c) => Show (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show e, Show1 m, Show a) => Show (ExceptT e m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • (Show w, Show1 m, Show a) => Show (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Show w, Show1 m, Show a) => Show (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • Show (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Show c => Show (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Show (f a), Show (g a)) => Show (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Show (f a), Show (g a)) => Show (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Show (f p), Show (g p)) => Show ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Show (f p), Show (g p)) => Show ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Show a, Show b, Show c, Show d) => Show (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show (f (g a)) => Show (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Show (f (g p)) => Show ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (f p) => Show (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Show a, Show b, Show c, Show d, Show e) => Show (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f) => Show (a, b, c, d, e, f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g) => Show (a, b, c, d, e, f, g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h) => Show (a, b, c, d, e, f, g, h)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i) => Show (a, b, c, d, e, f, g, h, i)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j) => Show (a, b, c, d, e, f, g, h, i, j)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k) => Show (a, b, c, d, e, f, g, h, i, j, k)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l) => Show (a, b, c, d, e, f, g, h, i, j, k, l)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n, Show o) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
typetype ShowS = String -> String
#

The shows functions return a function that prepends the output String to an existing String. This allows constant-time concatenation of results using function composition.

valueshowChar :: Char -> ShowS
#

utility function converting a Char to a show function that simply prepends the character unchanged.

classclass Fractional a => Floating a where
#

Trigonometric and hyperbolic functions and related functions.

The Haskell Report defines no laws for Floating. However, (+), (*) and exp are customarily expected to define an exponential field and have the following properties:

  • exp (a + b) = exp a * exp b

  • exp (fromInteger 0) = fromInteger 1

Methods

Instances10Floating, …
classclass (RealFrac a, Floating a) => RealFloat a where
#

Efficient, machine-independent access to the components of a floating-point number.

Methods

  • floatRadix :: a -> Integer

    a constant function, returning the radix of the representation (often 2)

  • floatDigits :: a -> Int

    a constant function, returning the number of digits of floatRadix in the significand

  • floatRange :: a -> (Int, Int)

    a constant function, returning the lowest and highest values the exponent may assume

  • decodeFloat :: a -> (Integer, Int)

    The function decodeFloat applied to a real floating-point number returns the significand expressed as an Integer and an appropriately scaled exponent (an Int). If decodeFloat x yields (m,n), then x is equal in value to m*b^^n, where b is the floating-point radix, and furthermore, either m and n are both zero or else b^(d-1) <= abs m < b^d, where d is the value of floatDigits x. In particular, decodeFloat 0 = (0,0). If the type contains a negative zero, also decodeFloat (-0.0) = (0,0). The result of decodeFloat x is unspecified if either of isNaN x or isInfinite x is True.

  • encodeFloat :: Integer -> Int -> a

    encodeFloat performs the inverse of decodeFloat in the sense that for finite x with the exception of -0.0, Prelude.uncurry encodeFloat (decodeFloat x) = x. encodeFloat m n is one of the two closest representable floating-point numbers to m*b^^n (or ±Infinity if overflow occurs); usually the closer, but if m contains too many bits, the result may be rounded in the wrong direction.

  • exponent :: a -> Int

    exponent corresponds to the second component of decodeFloat. exponent 0 = 0 and for finite nonzero x, exponent x = snd (decodeFloat x) + floatDigits x. If x is a finite floating-point number, it is equal in value to significand x * b ^^ exponent x, where b is the floating-point radix. The behaviour is unspecified on infinite or NaN values.

  • significand :: a -> a

    The first component of decodeFloat, scaled to lie in the open interval (-1,1), either 0.0 or of absolute value >= 1/b, where b is the floating-point radix. The behaviour is unspecified on infinite or NaN values.

  • scaleFloat :: Int -> a -> a

    multiplies a floating-point number by an integer power of the radix

  • isNaN :: a -> Bool

    True if the argument is an IEEE "not-a-number" (NaN) value

  • isInfinite :: a -> Bool

    True if the argument is an IEEE infinity or negative infinity

  • isDenormalized :: a -> Bool

    True if the argument is too small to be represented in normalized format

  • isNegativeZero :: a -> Bool

    True if the argument is an IEEE negative zero

  • isIEEE :: a -> Bool

    True if the argument is an IEEE floating point number

  • atan2 :: a -> a -> a

    a version of arctangent taking two real floating-point arguments. For real floating x and y, atan2 y x computes the angle (from the positive x-axis) of the vector from the origin to the point (x,y). atan2 y x returns a value in the range [-pi, pi]. It follows the Common Lisp semantics for the origin when signed zeroes are supported. atan2 y 1, with y in a type that is RealFloat, should return the same value as atan y. A default definition of atan2 is provided, but implementors can provide a more accurate implementation.

Instances8RealFloat, …
classclass Bounded a where
#

The Bounded class is used to name the upper and lower limits of a type. Ord is not a superclass of Bounded since types that are not totally ordered may also have upper and lower bounds.

The Bounded class may be derived for any enumeration type; minBound is the first constructor listed in the data declaration and maxBound is the last. Bounded may also be derived for single-constructor datatypes whose constituent types are in Bounded.

Methods

Instances106Bounded, …
valueconcat :: Foldable t => t [a] -> [a]
#

The concatenation of all the elements of a container of lists.

Examples

Basic usage:

Example1 expression
concat (Just [1, 2, 3])[1,2,3]
Example1 expression
concat (Left 42)[]
Example1 expression
concat [[1, 2, 3], [4, 5], [6], []][1,2,3,4,5,6]
typetype IOError = IOException
#

The Haskell 2010 type for exceptions in the IO monad. Any I/O operation may raise an IOError instead of returning a result. For a more general type of exception, including also those that arise in pure code, see Exception.

In Haskell 2010, this is an opaque type.

typetype ReadS a = String -> [(a, String)]
#

A parser for a type a, represented as a function that takes a String and returns a list of possible parses as (a,String) pairs.

Note that this kind of backtracking parser is very inefficient; reading a large structure may be quite slow (cf ReadP).

classclass Read a where
#

Parsing of Strings, producing values.

Derived instances of Read make the following assumptions, which derived instances of Text.Show.Show obey:

  • If the constructor is defined to be an infix operator, then the derived Read instance will parse only infix applications of the constructor (not the prefix form).

  • Associativity is not used to reduce the occurrence of parentheses, although precedence may be.

  • If the constructor is defined using record syntax, the derived Read will parse only the record-syntax form, and furthermore, the fields must be given in the same order as the original declaration.

  • The derived Read instance allows arbitrary Haskell whitespace between tokens of the input string. Extra parentheses are also allowed.

For example, given the declarations

infixr 5 :^:
data Tree a =  Leaf a  |  Tree a :^: Tree a

the derived instance of Read in Haskell 2010 is equivalent to

instance (Read a) => Read (Tree a) where

        readsPrec d r =  readParen (d > app_prec)
                         (\r -> [(Leaf m,t) |
                                 ("Leaf",s) <- lex r,
                                 (m,t) <- readsPrec (app_prec+1) s]) r

                      ++ readParen (d > up_prec)
                         (\r -> [(u:^:v,w) |
                                 (u,s) <- readsPrec (up_prec+1) r,
                                 (":^:",t) <- lex s,
                                 (v,w) <- readsPrec (up_prec+1) t]) r

          where app_prec = 10
                up_prec = 5

Note that right-associativity of :^: is unused.

The derived instance in GHC is equivalent to

instance (Read a) => Read (Tree a) where

        readPrec = parens $ (prec app_prec $ do
                                 Ident "Leaf" <- lexP
                                 m <- step readPrec
                                 return (Leaf m))

                     +++ (prec up_prec $ do
                                 u <- step readPrec
                                 Symbol ":^:" <- lexP
                                 v <- step readPrec
                                 return (u :^: v))

          where app_prec = 10
                up_prec = 5

        readListPrec = readListPrecDefault

Why do both readsPrec and readPrec exist, and why does GHC opt to implement readPrec in derived Read instances instead of readsPrec? The reason is that readsPrec is based on the ReadS type, and although ReadS is mentioned in the Haskell 2010 Report, it is not a very efficient parser data structure.

readPrec, on the other hand, is based on a much more efficient ReadPrec datatype (a.k.a "new-style parsers"), but its definition relies on the use of the RankNTypes language extension. Therefore, readPrec (and its cousin, readListPrec) are marked as GHC-only. Nevertheless, it is recommended to use readPrec instead of readsPrec whenever possible for the efficiency improvements it brings.

As mentioned above, derived Read instances in GHC will implement readPrec instead of readsPrec. The default implementations of readsPrec (and its cousin, readList) will simply use readPrec under the hood. If you are writing a Read instance by hand, it is recommended to write it like so:

instance Read T where
  readPrec     = ...
  readListPrec = readListPrecDefault

Methods

  • readsPrec :: Int -> ReadS a

    attempts to parse a value from the front of the string, returning a list of (parsed value, remaining string) pairs. If there is no successful parse, the returned list is empty.

    Derived instances of Read and Text.Show.Show satisfy the following:

    That is, readsPrec parses the string produced by showsPrec, and delivers the value that showsPrec started with.

  • readList :: ReadS [a]

    The method readList is provided to allow the programmer to give a specialised way of parsing lists of values. For example, this is used by the predefined Read instance of the Char type, where values of type String are expected to use double quotes, rather than square brackets.

Instances186Read, …
  • Read ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Read ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • Read ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • Read IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.Read

    Reading a Void value is always a parse error, considering Void as a data type with no constructors.

  • Read ByteOrderDefined in ghc-internal-9.1003.0 · GHC.Internal.ByteOrder
  • Read AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read VersionDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Version
  • Read CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Read WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Read AssociativityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read DecidedStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read SourceStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read SourceUnpackednessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Read ExitCodeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Read BufferModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Read NewlineDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Read NewlineModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Read IOModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.IOMode
  • Read Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read GCDetailsDefined in ghc-internal-9.1003.0 · GHC.Internal.Stats
  • Read RTSStatsDefined in ghc-internal-9.1003.0 · GHC.Internal.Stats
  • Read CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read LexemeDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read SomeCharDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Read SomeSymbolDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Read SomeNatDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • Read GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read CharDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read DayDefined in time-1.12.2 · Data.Time.Format.Parse · orphan
  • Read MonthDefined in time-1.12.2 · Data.Time.Calendar.Month

    Read as yyyy-mm.

  • Read QuarterDefined in time-1.12.2 · Data.Time.Calendar.Quarter

    Read as yyyy-Qn.

  • Read QuarterOfYearDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Read DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Read DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Read NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Read UTCTimeDefined in time-1.12.2 · Data.Time.Format.Parse · orphan
  • Read UniversalTimeDefined in time-1.12.2 · Data.Time.Format.Parse · orphan
  • Read LocalTimeDefined in time-1.12.2 · Data.Time.Format.Parse · orphan
  • Read TimeOfDayDefined in time-1.12.2 · Data.Time.Format.Parse · orphan
  • Read TimeZoneDefined in time-1.12.2 · Data.Time.Format.Parse · orphan

    This only works for ±HHMM format, single-letter military time-zones, and these time-zones: "UTC", "UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT", per RFC 822 section 5.

  • Read ZonedTimeDefined in time-1.12.2 · Data.Time.Format.Parse · orphan

    This only works for a zonedTimeZone in ±HHMM format, single-letter military time-zones, and these time-zones: "UTC", "UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT", per RFC 822 section 5.

  • Read RTLDFlagsDefined in unix-2.8.7.0 · System.Posix.DynamicLinker.Prim
  • Read CAttributesDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Read StatxFlagsDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Read StatxMaskDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Read OpenFileFlagsDefined in unix-2.8.7.0 · System.Posix.IO.Common
  • Read OpenModeDefined in unix-2.8.7.0 · System.Posix.IO.Common
  • Read GroupEntryDefined in unix-2.8.7.0 · System.Posix.User.Common
  • Read UserEntryDefined in unix-2.8.7.0 · System.Posix.User.Common
  • Read ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Read a => Read (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity

    This instance would be equivalent to the derived instances of the Identity newtype if the runIdentity field were removed

  • Read a => Read (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Read a => Read (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Read a => Read (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord

    This instance would be equivalent to the derived instances of the Down newtype if the getDown field were removed

  • Read a => Read (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read a => Read (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read a => Read (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read a => Read (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList
  • Read a => Read (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read m => Read (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Read p => Read (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Integral a, Read a) => Read (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • HasResolution a => Read (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Read (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Read (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read1 f, Read a) => Read (Lift f a)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • (Read1 m, Read a) => Read (MaybeT m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • (Ix a, Read a, Read b) => Read (Array a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Ix ix, Read ix, Read e, IArray UArray e) => Read (UArray ix e)Defined in array-0.5.8.0 · Data.Array.Base
  • (Read a, Read b) => Read (Arg a b)Defined in base-4.20.2.0 · Data.Semigroup
  • (Read a, Read b) => Read (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either
  • (Read a, Read b) => Read (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read (f a) => Read (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Read (f a) => Read (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read (f p) => Read (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read a => Read (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const

    This instance would be equivalent to the derived instances of the Const newtype if the getConst field were removed

  • Read a => Read (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • Coercible a b => Read (Coercion a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • (Read1 f, Read a) => Read (Backwards f a)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • (Read1 f, Read a) => Read (IdentityT f a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • (Read1 f, Read a) => Read (Reverse f a)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • (Read a, Read b, Read c) => Read (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read e, Read1 m, Read a) => Read (ExceptT e m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • (Read w, Read1 m, Read a) => Read (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Read w, Read1 m, Read a) => Read (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • a ~ b => Read (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Read c => Read (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read (f a), Read (g a)) => Read (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Read (f a), Read (g a)) => Read (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Read (f p), Read (g p)) => Read ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read (f p), Read (g p)) => Read ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read a, Read b, Read c, Read d) => Read (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • a ~~ b => Read (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Read (f (g a)) => Read (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Read (f (g p)) => Read ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read (f p) => Read (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read a, Read b, Read c, Read d, Read e) => Read (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f) => Read (a, b, c, d, e, f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g) => Read (a, b, c, d, e, f, g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) => Read (a, b, c, d, e, f, g, h)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i) => Read (a, b, c, d, e, f, g, h, i)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j) => Read (a, b, c, d, e, f, g, h, i, j)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k) => Read (a, b, c, d, e, f, g, h, i, j, k)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l) => Read (a, b, c, d, e, f, g, h, i, j, k, l)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n, Read o) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
valueuserError :: String -> IOError
#

Construct an IOError value with a string describing the error. The fail method of the IO instance of the Monad class raises a userError, thus:

instance Monad IO where
  ...
  fail s = ioError (userError s)
typetype FilePath = String
#

File and directory names are values of type String, whose precise meaning is operating system dependent. Files can be opened, yielding a handle which can then be used to operate on the contents of that file.

valuemaybe :: b -> (a -> b) -> Maybe a -> b
#

The maybe function takes a default value, a function, and a Maybe value. If the Maybe value is Nothing, the function returns the default value. Otherwise, it applies the function to the value inside the Just and returns the result.

Examples

Basic usage:

Example1 expression
maybe False odd (Just 3)True
Example1 expression
maybe False odd NothingFalse

Read an integer from a string using readMaybe. If we succeed, return twice the integer; that is, apply (*2) to it. If instead we fail to parse an integer, return 0 by default:

Example3 expressions
import GHC.Internal.Text.Read ( readMaybe )maybe 0 (*2) (readMaybe "5")10maybe 0 (*2) (readMaybe "")0

Apply show to a Maybe Int. If we have Just n, we want to show the underlying Int n. But if we have Nothing, we return the empty string instead of (for example) "Nothing":

Example2 expressions
maybe "" show (Just 5)"5"maybe "" show Nothing""
valuenotElem :: (Foldable t, Eq a) => a -> t a -> Bool
#

notElem is the negation of elem.

Examples

Basic usage:

Example1 expression
3 `notElem` []True
Example1 expression
3 `notElem` [1,2]True
Example1 expression
3 `notElem` [1,2,3,4,5]False

For infinite structures, notElem terminates if the value exists at a finite distance from the left side of the structure:

Example1 expression
3 `notElem` [1..]False
Example1 expression
3 `notElem` ([4..] ++ [3])* Hangs forever *
valueand :: Foldable t => t Bool -> Bool
#

and returns the conjunction of a container of Bools. For the result to be True, the container must be finite; False, however, results from a False value finitely far from the left end.

Examples

Basic usage:

Example1 expression
and []True
Example1 expression
and [True]True
Example1 expression
and [False]False
Example1 expression
and [True, True, False]False
Example1 expression
and (False : repeat True) -- Infinite list [False,True,True,True,...False
Example1 expression
and (repeat True)* Hangs forever *
valueany :: Foldable t => (a -> Bool) -> t a -> Bool
#

Determines whether any element of the structure satisfies the predicate.

Examples

Basic usage:

Example1 expression
any (> 3) []False
Example1 expression
any (> 3) [1,2]False
Example1 expression
any (> 3) [1,2,3,4,5]True
Example1 expression
any (> 3) [1..]True
Example1 expression
any (> 3) [0, -1..]* Hangs forever *
valueconcatMap :: Foldable t => (a -> [b]) -> t a -> [b]
#

Map a function over all the elements of a container and concatenate the resulting lists.

Examples

Basic usage:

Example1 expression
concatMap (take 3) [[1..], [10..], [100..], [1000..]][1,2,3,10,11,12,100,101,102,1000,1001,1002]
Example1 expression
concatMap (take 3) (Just [1..])[1,2,3]
valueor :: Foldable t => t Bool -> Bool
#

or returns the disjunction of a container of Bools. For the result to be False, the container must be finite; True, however, results from a True value finitely far from the left end.

Examples

Basic usage:

Example1 expression
or []False
Example1 expression
or [True]True
Example1 expression
or [False]False
Example1 expression
or [True, True, False]True
Example1 expression
or (True : repeat False) -- Infinite list [True,False,False,False,...True
Example1 expression
or (repeat False)* Hangs forever *
valuelex :: ReadS String
#

The lex function reads a single lexeme from the input, discarding initial white space, and returning the characters that constitute the lexeme. If the input string contains only white space, lex returns a single successful `lexeme' consisting of the empty string. (Thus lex "" = [("","")].) If there is no legal lexeme at the beginning of the input string, lex fails (i.e. returns []).

This lexer is not completely faithful to the Haskell lexical syntax in the following respects:

  • Qualified names are not handled properly

  • Octal and hexadecimal numerics are not recognized as a single token

  • Comments are not treated properly

valuelines :: String -> [String]
#

Splits the argument into a list of lines stripped of their terminating \n characters. The \n terminator is optional in a final non-empty line of the argument string.

When the argument string is empty, or ends in a \n character, it can be recovered by passing the result of lines to the unlines function. Otherwise, unlines appends the missing terminating \n. This makes unlines . lines idempotent:

(unlines . lines) . (unlines . lines) = (unlines . lines)
Examples
Example1 expression
lines ""           -- empty input contains no lines[]
Example1 expression
lines "\n"         -- single empty line[""]
Example1 expression
lines "one"        -- single unterminated line["one"]
Example1 expression
lines "one\n"      -- single non-empty line["one"]
Example1 expression
lines "one\n\n"    -- second line is empty["one",""]
Example1 expression
lines "one\ntwo"   -- second line is unterminated["one","two"]
Example1 expression
lines "one\ntwo\n" -- two non-empty lines["one","two"]
valueunlines :: [String] -> String
#

Appends a \n character to each input string, then concatenates the results. Equivalent to foldMap (s -> s ++ "\n").

Examples
Example1 expression
unlines ["Hello", "World", "!"]"Hello\nWorld\n!\n"

Note that unlines . lines /= id when the input is not \n-terminated:

Example1 expression
unlines . lines $ "foo\nbar""foo\nbar\n"
valueunwords :: [String] -> String
#

unwords joins words with separating spaces (U+0020 SPACE).

unwords is neither left nor right inverse of words:

Example2 expressions
words (unwords [" "])[]unwords (words "foo\nbar")"foo bar"
Examples
Example1 expression
unwords ["Lorem", "ipsum", "dolor"]"Lorem ipsum dolor"
Example1 expression
unwords ["foo", "bar", "", "baz"]"foo bar  baz"
valuewords :: String -> [String]
#

words breaks a string up into a list of words, which were delimited by white space (as defined by isSpace). This function trims any white spaces at the beginning and at the end.

Examples
Example1 expression
words "Lorem ipsum\ndolor"["Lorem","ipsum","dolor"]
Example1 expression
words " foo bar "["foo","bar"]
valuelookup :: Eq a => a -> [(a, b)] -> Maybe b
#

\mathcal{O}(n). lookup key assocs looks up a key in an association list. For the result to be Nothing, the list must be finite.

Examples
Example1 expression
lookup 2 []Nothing
Example1 expression
lookup 2 [(1, "first")]Nothing
Example1 expression
lookup 2 [(1, "first"), (2, "second"), (3, "third")]Just "second"
valueunzip3 :: [(a, b, c)] -> ([a], [b], [c])
#

The unzip3 function takes a list of triples and returns three lists of the respective components, analogous to unzip.

Examples
Example1 expression
unzip3 []([],[],[])
Example1 expression
unzip3 [(1, 'a', True), (2, 'b', False)]([1,2],"ab",[True,False])
valuezip3 :: [a] -> [b] -> [c] -> [(a, b, c)]
#

zip3 takes three lists and returns a list of triples, analogous to zip. It is capable of list fusion, but it is restricted to its first list argument and its resulting list.

valuezipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
#

\mathcal{O}(\min(l,m,n)). The zipWith3 function takes a function which combines three elements, as well as three lists and returns a list of the function applied to corresponding elements, analogous to zipWith. It is capable of list fusion, but it is restricted to its first list argument and its resulting list.

zipWith3 (,,) xs ys zs == zip3 xs ys zs
zipWith3 f [x1,x2,x3..] [y1,y2,y3..] [z1,z2,z3..] == [f x1 y1 z1, f x2 y2 z2, f x3 y3 z3..]
Examples
Example1 expression
zipWith3 (\x y z -> [x, y, z]) "123" "abc" "xyz"["1ax","2by","3cz"]
Example1 expression
zipWith3 (\x y z -> (x * y) + z) [1, 2, 3] [4, 5, 6] [7, 8, 9][11,18,27]
valuegcd :: Integral a => a -> a -> a
#

gcd x y is the non-negative factor of both x and y of which every common factor of x and y is also a factor; for example gcd 4 2 = 2, gcd (-4) 6 = 2, gcd 0 4 = 4. gcd 0 0 = 0. (That is, the common divisor that is "greatest" in the divisibility preordering.)

Note: Since for signed fixed-width integer types, abs minBound < 0, the result may be negative if one of the arguments is minBound (and necessarily is if the other is 0 or minBound) for such types.

valuelcm :: Integral a => a -> a -> a
#

lcm x y is the smallest positive integer that both x and y divide.

valueread :: Read a => String -> a
#

The read function reads input from a string, which must be completely consumed by the input process. read fails with an error if the parse is unsuccessful, and it is therefore discouraged from being used in real applications. Use readMaybe or readEither for safe alternatives.

Example1 expression
read "123" :: Int123
Example1 expression
read "hello" :: Int*** Exception: Prelude.read: no parse
valuesubtract :: Num a => a -> a -> a
#

the same as flip (-).

Because - is treated specially in the Haskell grammar, (- e) is not a section, but an application of prefix negation. However, (subtract exp) is equivalent to the disallowed section.

valueappendFile :: FilePath -> String -> IO ()
#

The computation appendFile file str function appends the string str, to the file file.

Note that writeFile and appendFile write a literal string to a file. To write a value of any printable type, as with print, use the show function to convert the value to a string first.

main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]])
valueinteract :: (String -> String) -> IO ()
#

The interact function takes a function of type String->String as its argument. The entire input from the standard input device is passed to this function as its argument, and the resulting string is output on the standard output device.

valuereadIO :: Read a => String -> IO a
#

The readIO function is similar to read except that it signals parse failure to the IO monad instead of terminating the program.

valueprint :: Show a => a -> IO ()
#

The print function outputs a value of any printable type to the standard output device. Printable types are those that are instances of class Show; print converts values to strings for output using the show operation and adds a newline.

For example, a program to print the first 20 integers and their powers of 2 could be written as:

main = print ([(n, 2^n) | n <- [0..19]])
valueseq :: a -> b -> b
#

The value of seq a b is bottom if a is bottom, and otherwise equal to b. In other words, it evaluates the first argument a to weak head normal form (WHNF). seq is usually introduced to improve performance by avoiding unneeded laziness.

A note on evaluation order: the expression seq a b does not guarantee that a will be evaluated before b. The only guarantee given by seq is that the both a and b will be evaluated before seq returns a value. In particular, this means that b may be evaluated before a. If you need to guarantee a specific order of evaluation, you must use the function pseq from the "parallel" package.