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

Modulefoundation-0.0.30Haskell2010

Foundation

I tried to picture clusters of information As they moved through the computer What do they look like?

Alternative Prelude

  • 39 types
  • 34 classes
  • 50 values
  • Packagefoundation-0.0.30
  • Exports130
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceFoundation.hs

Standard

0 declarations

Operators

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
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.

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

Boolean "and", lazy in the second argument

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

Boolean "or", lazy in the second argument

method(.) :: cat b c -> cat a b -> cat a c
#

morphism composition

Functions

valueotherwise :: Bool
#

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

 f x | x < 0     = ...
     | otherwise = ...
datadata Tuple2 a b
#

Strict tuple (a,b)

Constructors

Instances16Nthable, Eq, Data, Ord, Show, Generic, …
datadata Tuple3 a b c
#

Strict tuple (a,b,c)

Constructors

Instances20Nthable, Eq, Data, Ord, Show, Generic, …
datadata Tuple4 a b c d
#

Strict tuple (a,b,c,d)

Constructors

Instances22Nthable, Eq, Data, Ord, Show, Generic, …
classclass Fstable a where
#

Class of product types that have a first element

Associated types

Methods

Instances6Fstable
  • Fstable (Tuple2 a b)Defined in foundation-0.0.30 · Foundation.Tuple
  • Fstable (a, b)Defined in foundation-0.0.30 · Foundation.Tuple
  • Fstable (Tuple3 a b c)Defined in foundation-0.0.30 · Foundation.Tuple
  • Fstable (a, b, c)Defined in foundation-0.0.30 · Foundation.Tuple
  • Fstable (Tuple4 a b c d)Defined in foundation-0.0.30 · Foundation.Tuple
  • Fstable (a, b, c, d)Defined in foundation-0.0.30 · Foundation.Tuple
classclass Sndable a where
#

Class of product types that have a second element

Associated types

Methods

Instances6Sndable
  • Sndable (Tuple2 a b)Defined in foundation-0.0.30 · Foundation.Tuple
  • Sndable (a, b)Defined in foundation-0.0.30 · Foundation.Tuple
  • Sndable (Tuple3 a b c)Defined in foundation-0.0.30 · Foundation.Tuple
  • Sndable (a, b, c)Defined in foundation-0.0.30 · Foundation.Tuple
  • Sndable (Tuple4 a b c d)Defined in foundation-0.0.30 · Foundation.Tuple
  • Sndable (a, b, c, d)Defined in foundation-0.0.30 · Foundation.Tuple
classclass Thdable a where
#

Class of product types that have a third element

Associated types

Methods

Instances4Thdable
  • Thdable (Tuple3 a b c)Defined in foundation-0.0.30 · Foundation.Tuple
  • Thdable (a, b, c)Defined in foundation-0.0.30 · Foundation.Tuple
  • Thdable (Tuple4 a b c d)Defined in foundation-0.0.30 · Foundation.Tuple
  • Thdable (a, b, c, d)Defined in foundation-0.0.30 · Foundation.Tuple
familytype family ProductFirst a
#
Instances6ProductFirst
  • type ProductFirst (Tuple2 a b) = aDefined in foundation-0.0.30 · Foundation.Tuple
  • type ProductFirst (Tuple3 a b c) = aDefined in foundation-0.0.30 · Foundation.Tuple
  • type ProductFirst (Tuple4 a b c d) = aDefined in foundation-0.0.30 · Foundation.Tuple
  • type ProductFirst (a, b) = aDefined in foundation-0.0.30 · Foundation.Tuple
  • type ProductFirst (a, b, c) = aDefined in foundation-0.0.30 · Foundation.Tuple
  • type ProductFirst (a, b, c, d) = aDefined in foundation-0.0.30 · Foundation.Tuple
familytype family ProductSecond a
#
Instances6ProductSecond
  • type ProductSecond (Tuple2 a b) = bDefined in foundation-0.0.30 · Foundation.Tuple
  • type ProductSecond (Tuple3 a b c) = bDefined in foundation-0.0.30 · Foundation.Tuple
  • type ProductSecond (Tuple4 a b c d) = bDefined in foundation-0.0.30 · Foundation.Tuple
  • type ProductSecond (a, b) = bDefined in foundation-0.0.30 · Foundation.Tuple
  • type ProductSecond (a, b, c) = bDefined in foundation-0.0.30 · Foundation.Tuple
  • type ProductSecond (a, b, c, d) = bDefined in foundation-0.0.30 · Foundation.Tuple
familytype family ProductThird a
#
Instances4ProductThird
  • type ProductThird (Tuple3 a b c) = cDefined in foundation-0.0.30 · Foundation.Tuple
  • type ProductThird (Tuple4 a b c d) = cDefined in foundation-0.0.30 · Foundation.Tuple
  • type ProductThird (a, b, c) = cDefined in foundation-0.0.30 · Foundation.Tuple
  • type ProductThird (a, b, c, d) = cDefined in foundation-0.0.30 · Foundation.Tuple
methodid :: cat a a
#

the identity morphism

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""
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
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"
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]
valueputStrLn :: String -> IO ()
#

Print a string with a newline to standard output

valuegetArgs :: IO [String]
#

Returns a list of the program's command line arguments (not including the program name).

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]
valuecurry :: ((a, b) -> c) -> a -> b -> c
#

Convert an uncurried function to a curried function.

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

Swap the components of a pair.

valueuntil :: (a -> Bool) -> (a -> a) -> a -> a
#

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

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.

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.

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.

classclass NormalForm a where
#

Data that can be fully evaluated in Normal Form

Instances70NormalForm, …

Type classes

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)".

Instances341Show, …
  • Show ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • Show TimeoutDefined in base-4.20.2.0 · System.Timeout
  • Show EndiannessDefined in basement-0.0.16 · Basement.Endianness
  • Show InvalidRecastDefined in basement-0.0.16 · Basement.Exception
  • Show NonEmptyCollectionIsEmptyDefined in basement-0.0.16 · Basement.Exception
  • Show OutOfBoundDefined in basement-0.0.16 · Basement.Exception
  • Show OutOfBoundOperationDefined in basement-0.0.16 · Basement.Exception
  • Show RecastDestinationSizeDefined in basement-0.0.16 · Basement.Exception
  • Show RecastSourceSizeDefined in basement-0.0.16 · Basement.Exception
  • Show EncodingDefined in basement-0.0.16 · Basement.String
  • Show ASCII7_InvalidDefined in basement-0.0.16 · Basement.String.Encoding.ASCII7
  • Show ISO_8859_1_InvalidDefined in basement-0.0.16 · Basement.String.Encoding.ISO_8859_1
  • Show UTF16_InvalidDefined in basement-0.0.16 · Basement.String.Encoding.UTF16
  • Show UTF32_InvalidDefined in basement-0.0.16 · Basement.String.Encoding.UTF32
  • Show AsciiStringDefined in basement-0.0.16 · Basement.Types.AsciiString
  • Show Char7Defined in basement-0.0.16 · Basement.Types.Char7
  • Show FileSizeDefined in basement-0.0.16 · Basement.Types.OffsetSize
  • Show Word128Defined in basement-0.0.16 · Basement.Types.Word128
  • Show Word256Defined in basement-0.0.16 · Basement.Types.Word256
  • Show StringDefined in basement-0.0.16 · Basement.UTF8.Base
  • Show ValidationFailureDefined in basement-0.0.16 · Basement.UTF8.Types
  • Show BitmapDefined in foundation-0.0.30 · Foundation.Array.Bitmap
  • Show DisplayOptionDefined in foundation-0.0.30 · Foundation.Check.Config
  • Show PropertyResultDefined in foundation-0.0.30 · Foundation.Check.Types
  • Show TestResultDefined in foundation-0.0.30 · Foundation.Check.Types
  • Show MemoryAdviceDefined in foundation-0.0.30 · Foundation.Foreign.MemoryMap.Posix
  • Show MemoryMapFlagDefined in foundation-0.0.30 · Foundation.Foreign.MemoryMap.Posix
  • Show MemoryProtectionDefined in foundation-0.0.30 · Foundation.Foreign.MemoryMap.Posix
  • Show MemorySyncFlagDefined in foundation-0.0.30 · Foundation.Foreign.MemoryMap.Posix
  • Show CSVDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • Show EscapingDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • Show FieldDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • Show RowDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • Show FNV1Hash32Defined in foundation-0.0.30 · Foundation.Hashing.FNV
  • Show FNV1Hash64Defined in foundation-0.0.30 · Foundation.Hashing.FNV
  • Show SipHashDefined in foundation-0.0.30 · Foundation.Hashing.SipHash
  • Show IPv4Defined in foundation-0.0.30 · Foundation.Network.IPv4
  • Show IPv6Defined in foundation-0.0.30 · Foundation.Network.IPv6
  • Show AndDefined in foundation-0.0.30 · Foundation.Parser
  • Show ConditionDefined in foundation-0.0.30 · Foundation.Parser
  • Show NoMoreDefined in foundation-0.0.30 · Foundation.Parser
  • Show PartialErrorDefined in foundation-0.0.30 · Foundation.Partial
  • Show EntropySystemMissingDefined in foundation-0.0.30 · Foundation.System.Entropy.Common
  • Show ArchDefined in foundation-0.0.30 · Foundation.System.Info
  • Show OSDefined in foundation-0.0.30 · Foundation.System.Info
  • Show NanoSecondsDefined in foundation-0.0.30 · Foundation.Time.Types
  • Show SecondsDefined in foundation-0.0.30 · Foundation.Time.Types
  • Show UUIDDefined in foundation-0.0.30 · Foundation.UUID
  • Show FileNameDefined in foundation-0.0.30 · Foundation.VFS.FilePath
  • Show FileName_InvalidDefined in foundation-0.0.30 · Foundation.VFS.FilePath
  • Show FilePathDefined in foundation-0.0.30 · Foundation.VFS.FilePath
  • Show FilePath_InvalidDefined in foundation-0.0.30 · Foundation.VFS.FilePath
  • Show RelativityDefined in foundation-0.0.30 · Foundation.VFS.FilePath
  • Show IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • 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 ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show (Bits n)Defined in basement-0.0.16 · Basement.Bits
  • Show (Zn n)Defined in basement-0.0.16 · Basement.Bounded
  • Show (Zn64 n)Defined in basement-0.0.16 · Basement.Bounded
  • Show (FinalPtr a)Defined in basement-0.0.16 · Basement.FinalPtr
  • Show (CountOf ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • Show (Offset ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • Show (ParseError String)Defined in foundation-0.0.30 · Foundation.Parser
  • 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 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 (Array a)Defined in basement-0.0.16 · Basement.BoxedArray
  • Show a => Show (BE a)Defined in basement-0.0.16 · Basement.Endianness
  • Show a => Show (LE a)Defined in basement-0.0.16 · Basement.Endianness
  • Show a => Show (NonEmpty a)Defined in basement-0.0.16 · Basement.NonEmpty
  • Show a => Show (DList a)Defined in foundation-0.0.30 · Foundation.List.DList
  • 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 (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 input => Show (ParseError input)Defined in foundation-0.0.30 · Foundation.Parser
  • 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
  • (PrimType ty, Show ty) => Show (Block ty)Defined in basement-0.0.16 · Basement.Block.Base
  • (PrimType ty, Show ty) => Show (UArray ty)Defined in basement-0.0.16 · Basement.UArray.Base
  • (PrimType ty, Show ty) => Show (ChunkedUArray ty)Defined in foundation-0.0.30 · Foundation.Array.Chunked.Unboxed
  • 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
  • Show a => Show (ListN n a)Defined in basement-0.0.16 · Basement.Sized.List
  • Show a => Show (Vect n a)Defined in basement-0.0.16 · Basement.Sized.Vect
  • (PrimType a, Show a) => Show (BlockN n a)Defined in basement-0.0.16 · Basement.Sized.Block
  • (PrimType a, Show a) => Show (UVect n a)Defined in basement-0.0.16 · Basement.Sized.UVect
  • (Ix a, Show a, Show b) => Show (Array a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Arr
  • (Show a, Show b) => Show (Arg a b)Defined in base-4.20.2.0 · Data.Semigroup
  • (Show a, Show b) => Show (These a b)Defined in basement-0.0.16 · Basement.These
  • (Show a, Show b) => Show (Tuple2 a b)Defined in foundation-0.0.30 · Foundation.Tuple
  • (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 k, Show input) => Show (Result input k)Defined in foundation-0.0.30 · Foundation.Parser
  • 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 b, Show c) => Show (Tuple3 a b c)Defined in foundation-0.0.30 · Foundation.Tuple
  • (Show a, Show b, Show c) => Show (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • 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 (Tuple4 a b c d)Defined in foundation-0.0.30 · Foundation.Tuple
  • (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
valueshow :: Show a => a -> String
#

Use the Show class to create a String.

Note that this is not efficient, since an intermediate [Char] is going to be created before turning into a real String.

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

Instances218Ord, …
  • 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 EncodingDefined in basement-0.0.16 · Basement.String
  • Ord UTF32_InvalidDefined in basement-0.0.16 · Basement.String.Encoding.UTF32
  • Ord AsciiStringDefined in basement-0.0.16 · Basement.Types.AsciiString
  • Ord Char7Defined in basement-0.0.16 · Basement.Types.Char7
  • Ord FileSizeDefined in basement-0.0.16 · Basement.Types.OffsetSize
  • Ord AddrDefined in basement-0.0.16 · Basement.Types.Ptr
  • Ord Word128Defined in basement-0.0.16 · Basement.Types.Word128
  • Ord Word256Defined in basement-0.0.16 · Basement.Types.Word256
  • Ord StringDefined in basement-0.0.16 · Basement.UTF8.Base
  • Ord BitmapDefined in foundation-0.0.30 · Foundation.Array.Bitmap
  • Ord DisplayOptionDefined in foundation-0.0.30 · Foundation.Check.Config
  • Ord EscapingDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • Ord FNV1Hash32Defined in foundation-0.0.30 · Foundation.Hashing.FNV
  • Ord FNV1Hash64Defined in foundation-0.0.30 · Foundation.Hashing.FNV
  • Ord SipHashDefined in foundation-0.0.30 · Foundation.Hashing.SipHash
  • Ord IPv4Defined in foundation-0.0.30 · Foundation.Network.IPv4
  • Ord IPv6Defined in foundation-0.0.30 · Foundation.Network.IPv6
  • Ord ArchDefined in foundation-0.0.30 · Foundation.System.Info
  • Ord OSDefined in foundation-0.0.30 · Foundation.System.Info
  • Ord NanoSecondsDefined in foundation-0.0.30 · Foundation.Time.Types
  • Ord SecondsDefined in foundation-0.0.30 · Foundation.Time.Types
  • Ord UUIDDefined in foundation-0.0.30 · Foundation.UUID
  • Ord FilePathDefined in foundation-0.0.30 · Foundation.VFS.FilePath
  • 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 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 ()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 (Bits n)Defined in basement-0.0.16 · Basement.Bits
  • Ord (Zn n)Defined in basement-0.0.16 · Basement.Bounded
  • Ord (Zn64 n)Defined in basement-0.0.16 · Basement.Bounded
  • Ord (FinalPtr a)Defined in basement-0.0.16 · Basement.FinalPtr
  • Ord (CountOf ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • Ord (Offset ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • 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 (Array a)Defined in basement-0.0.16 · Basement.BoxedArray
  • Ord a => Ord (DList a)Defined in foundation-0.0.30 · Foundation.List.DList
  • 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 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
  • (ByteSwap a, Ord a) => Ord (BE a)Defined in basement-0.0.16 · Basement.Endianness
  • (ByteSwap a, Ord a) => Ord (LE a)Defined in basement-0.0.16 · Basement.Endianness
  • (PrimType ty, Ord ty) => Ord (Block ty)Defined in basement-0.0.16 · Basement.Block.Base
  • (PrimType ty, Ord ty) => Ord (UArray ty)Defined in basement-0.0.16 · Basement.UArray.Base
  • (PrimType ty, Ord ty) => Ord (ChunkedUArray ty)Defined in foundation-0.0.30 · Foundation.Array.Chunked.Unboxed
  • 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
  • Ord a => Ord (ListN n a)Defined in basement-0.0.16 · Basement.Sized.List
  • (PrimType a, Ord a) => Ord (BlockN n a)Defined in basement-0.0.16 · Basement.Sized.Block
  • (Ix i, Ord e) => Ord (Array i e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Arr
  • (Ord a, Ord b) => Ord (These a b)Defined in basement-0.0.16 · Basement.These
  • (Ord a, Ord b) => Ord (Tuple2 a b)Defined in foundation-0.0.30 · Foundation.Tuple
  • (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
  • (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 (Tuple3 a b c)Defined in foundation-0.0.30 · Foundation.Tuple
  • (Ord a, Ord b, Ord c) => Ord (a, b, c)Defined in ghc-prim-0.12.0 · GHC.Classes
  • 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 (Tuple4 a b c d)Defined in foundation-0.0.30 · Foundation.Tuple
  • (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
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

Instances297Eq, …
  • Eq ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • Eq TimeoutDefined in base-4.20.2.0 · System.Timeout
  • Eq PinnedStatusDefined in basement-0.0.16 · Basement.Compat.Primitive
  • Eq EndiannessDefined in basement-0.0.16 · Basement.Endianness
  • Eq OutOfBoundOperationDefined in basement-0.0.16 · Basement.Exception
  • Eq RecastDestinationSizeDefined in basement-0.0.16 · Basement.Exception
  • Eq RecastSourceSizeDefined in basement-0.0.16 · Basement.Exception
  • Eq EncodingDefined in basement-0.0.16 · Basement.String
  • Eq ASCII7_InvalidDefined in basement-0.0.16 · Basement.String.Encoding.ASCII7
  • Eq ISO_8859_1_InvalidDefined in basement-0.0.16 · Basement.String.Encoding.ISO_8859_1
  • Eq UTF16_InvalidDefined in basement-0.0.16 · Basement.String.Encoding.UTF16
  • Eq UTF32_InvalidDefined in basement-0.0.16 · Basement.String.Encoding.UTF32
  • Eq AsciiStringDefined in basement-0.0.16 · Basement.Types.AsciiString
  • Eq Char7Defined in basement-0.0.16 · Basement.Types.Char7
  • Eq FileSizeDefined in basement-0.0.16 · Basement.Types.OffsetSize
  • Eq AddrDefined in basement-0.0.16 · Basement.Types.Ptr
  • Eq Word128Defined in basement-0.0.16 · Basement.Types.Word128
  • Eq Word256Defined in basement-0.0.16 · Basement.Types.Word256
  • Eq StringDefined in basement-0.0.16 · Basement.UTF8.Base
  • Eq CMDefined in basement-0.0.16 · Basement.UTF8.Types
  • Eq ValidationFailureDefined in basement-0.0.16 · Basement.UTF8.Types
  • Eq BitmapDefined in foundation-0.0.30 · Foundation.Array.Bitmap
  • Eq DisplayOptionDefined in foundation-0.0.30 · Foundation.Check.Config
  • Eq PropertyResultDefined in foundation-0.0.30 · Foundation.Check.Types
  • Eq MemoryAdviceDefined in foundation-0.0.30 · Foundation.Foreign.MemoryMap.Posix
  • Eq MemoryMapFlagDefined in foundation-0.0.30 · Foundation.Foreign.MemoryMap.Posix
  • Eq MemoryProtectionDefined in foundation-0.0.30 · Foundation.Foreign.MemoryMap.Posix
  • Eq MemorySyncFlagDefined in foundation-0.0.30 · Foundation.Foreign.MemoryMap.Posix
  • Eq CSVDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • Eq EscapingDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • Eq FieldDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • Eq RowDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • Eq FNV1Hash32Defined in foundation-0.0.30 · Foundation.Hashing.FNV
  • Eq FNV1Hash64Defined in foundation-0.0.30 · Foundation.Hashing.FNV
  • Eq SipHashDefined in foundation-0.0.30 · Foundation.Hashing.SipHash
  • Eq IPv4Defined in foundation-0.0.30 · Foundation.Network.IPv4
  • Eq IPv6Defined in foundation-0.0.30 · Foundation.Network.IPv6
  • Eq SignDefined in foundation-0.0.30 · Foundation.Numerical
  • Eq AndDefined in foundation-0.0.30 · Foundation.Parser
  • Eq ConditionDefined in foundation-0.0.30 · Foundation.Parser
  • Eq NoMoreDefined in foundation-0.0.30 · Foundation.Parser
  • Eq PartialErrorDefined in foundation-0.0.30 · Foundation.Partial
  • Eq EntropySystemMissingDefined in foundation-0.0.30 · Foundation.System.Entropy.Common
  • Eq ArchDefined in foundation-0.0.30 · Foundation.System.Info
  • Eq OSDefined in foundation-0.0.30 · Foundation.System.Info
  • Eq NanoSecondsDefined in foundation-0.0.30 · Foundation.Time.Types
  • Eq SecondsDefined in foundation-0.0.30 · Foundation.Time.Types
  • Eq UUIDDefined in foundation-0.0.30 · Foundation.UUID
  • Eq FileNameDefined in foundation-0.0.30 · Foundation.VFS.FilePath
  • Eq FilePathDefined in foundation-0.0.30 · Foundation.VFS.FilePath
  • Eq RelativityDefined in foundation-0.0.30 · Foundation.VFS.FilePath
  • 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 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 ()Defined in ghc-prim-0.12.0 · GHC.Classes
  • PrimType ty => Eq (ChunkedUArray ty)Defined in foundation-0.0.30 · Foundation.Array.Chunked.Unboxed
  • 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 (Bits n)Defined in basement-0.0.16 · Basement.Bits
  • Eq (Zn n)Defined in basement-0.0.16 · Basement.Bounded
  • Eq (Zn64 n)Defined in basement-0.0.16 · Basement.Bounded
  • Eq (FinalPtr a)Defined in basement-0.0.16 · Basement.FinalPtr
  • Eq (CountOf ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • Eq (Offset ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • 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 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 (Array a)Defined in basement-0.0.16 · Basement.BoxedArray
  • Eq a => Eq (BE a)Defined in basement-0.0.16 · Basement.Endianness
  • Eq a => Eq (LE a)Defined in basement-0.0.16 · Basement.Endianness
  • Eq a => Eq (NonEmpty a)Defined in basement-0.0.16 · Basement.NonEmpty
  • Eq a => Eq (DList a)Defined in foundation-0.0.30 · Foundation.List.DList
  • 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 (a)Defined in ghc-prim-0.12.0 · GHC.Classes
  • Eq a => Eq [a]Defined in ghc-prim-0.12.0 · GHC.Classes
  • 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
  • (PrimType ty, Eq ty) => Eq (Block ty)Defined in basement-0.0.16 · Basement.Block.Base
  • (PrimType ty, Eq ty) => Eq (UArray ty)Defined in basement-0.0.16 · Basement.UArray.Base
  • PrimType a => Eq (BlockN n a)Defined in basement-0.0.16 · Basement.Sized.Block
  • PrimType a => Eq (UVect n a)Defined in basement-0.0.16 · Basement.Sized.UVect
  • 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
  • Eq a => Eq (ListN n a)Defined in basement-0.0.16 · Basement.Sized.List
  • Eq a => Eq (Vect n a)Defined in basement-0.0.16 · Basement.Sized.Vect
  • (Ix i, Eq e) => Eq (Array i e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Arr
  • (Eq a, Eq b) => Eq (These a b)Defined in basement-0.0.16 · Basement.These
  • (Eq a, Eq b) => Eq (Tuple2 a b)Defined in foundation-0.0.30 · Foundation.Tuple
  • (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 (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
  • (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 (Tuple3 a b c)Defined in foundation-0.0.30 · Foundation.Tuple
  • (Eq a, Eq b, Eq c) => Eq (a, b, c)Defined in ghc-prim-0.12.0 · GHC.Classes
  • 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 (Tuple4 a b c d)Defined in foundation-0.0.30 · Foundation.Tuple
  • (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
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

Instances115Bounded, …
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] = []
Instances121Enum, …
  • Enum EncodingDefined in basement-0.0.16 · Basement.String
  • Enum UTF32_InvalidDefined in basement-0.0.16 · Basement.String.Encoding.UTF32
  • Enum Word128Defined in basement-0.0.16 · Basement.Types.Word128
  • Enum Word256Defined in basement-0.0.16 · Basement.Types.Word256
  • Enum DisplayOptionDefined in foundation-0.0.30 · Foundation.Check.Config
  • Enum EscapingDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • Enum ArchDefined in foundation-0.0.30 · Foundation.System.Info
  • Enum OSDefined in foundation-0.0.30 · Foundation.System.Info
  • Enum NanoSecondsDefined in foundation-0.0.30 · Foundation.Time.Types
  • Enum SecondsDefined in foundation-0.0.30 · Foundation.Time.Types
  • Enum IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • 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 ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • SizeValid n => Enum (Bits n)Defined in basement-0.0.16 · Basement.Bits
  • Enum (CountOf ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • Enum (Offset ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • 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
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
Instances91Functor, …
  • 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 ArrayDefined in basement-0.0.16 · Basement.BoxedArray
  • Functor GenDefined in foundation-0.0.30 · Foundation.Check.Gen
  • Functor CheckMainDefined in foundation-0.0.30 · Foundation.Check.Main
  • Functor CheckDefined in foundation-0.0.30 · Foundation.Check.Types
  • Functor DListDefined in foundation-0.0.30 · Foundation.List.DList
  • Functor PartialDefined in foundation-0.0.30 · Foundation.Partial
  • Functor TimingPlanDefined in foundation-0.0.30 · Foundation.Timing.Main
  • 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 []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 (Vect n)Defined in basement-0.0.16 · Basement.Sized.Vect
  • Functor (Parser input)Defined in foundation-0.0.30 · Foundation.Parser
  • Functor (Result input)Defined in foundation-0.0.30 · Foundation.Parser
  • Functor (MonadRandomState gen)Defined in foundation-0.0.30 · Foundation.Random.DRG
  • 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 m => Functor (ResourceT m)Defined in foundation-0.0.30 · Foundation.Conduit.Internal
  • Functor m => Functor (IdentityT m)Defined in foundation-0.0.30 · Foundation.Monad.Identity
  • Monad m => Functor (WrappedMonad m)Defined in base-4.20.2.0 · Control.Applicative
  • 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 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 m => Functor (ExceptT e m)Defined in foundation-0.0.30 · Foundation.Monad.Except
  • Functor m => Functor (ReaderT r m)Defined in foundation-0.0.30 · Foundation.Monad.Reader
  • Functor m => Functor (StateT s m)Defined in foundation-0.0.30 · Foundation.Monad.State
  • Functor m => Functor (Kleisli m a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Arrow
  • Monad m => Functor (Reader r m)Defined in basement-0.0.16 · Basement.Compat.MonadTrans
  • Monad m => Functor (State s m)Defined in basement-0.0.16 · Basement.Compat.MonadTrans
  • Monad m => Functor (ZipSink i m)Defined in foundation-0.0.30 · Foundation.Conduit.Internal
  • 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 (Conduit i o m)Defined in foundation-0.0.30 · Foundation.Conduit.Internal
  • 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 ((->) 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 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
  • Applicative m => Functor (Pipe l i o u m)Defined in foundation-0.0.30 · Foundation.Conduit.Internal
  • Functor (Tuple6 a b c d e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monad state => Functor (Builder collection mutCollection step state err)Defined in basement-0.0.16 · Basement.MutableBuilder
  • Functor (Tuple7 a b c d e f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
classclass Integral a where
#

Integral Literal support

e.g. 123 :: Integer 123 :: Word8

Methods

Instances48Integral, …
classclass Fractional a where
#

Fractional Literal support

e.g. 1.2 :: Double 0.03 :: Float

Methods

Instances5Fractional
classclass HasNegation a where
#

Negation support

e.g. -(f x)

Methods

Instances26HasNegation, …
classclass (forall a. Functor (p a)) => Bifunctor (p :: Type -> Type -> Type) where
#

A bifunctor is a type constructor that takes two type arguments and is a functor in both arguments. That is, unlike with Functor, a type constructor such as Either does not need to be partially applied for a Bifunctor instance, and the methods in this class permit mapping functions over the Left value or the Right value, or both at the same time.

Formally, the class Bifunctor represents a bifunctor from Hask -> Hask.

Intuitively it is a bifunctor where both the first and second arguments are covariant.

The class definition of a Bifunctor p uses the QuantifiedConstraints language extension to quantify over the first type argument a in its context. The context requires that p a must be a Functor for all a. In other words a partially applied Bifunctor must be a Functor. This makes Functor a superclass of Bifunctor such that a function with a Bifunctor constraint may use fmap in its implementation. Functor has been a quantified superclass of Bifunctor since base-4.18.0.0.

You can define a Bifunctor by either defining bimap or by defining both first and second. The second method must agree with fmap:

second ≡ fmap

From this it follows that:

second id ≡ id

If you supply bimap, you should ensure that:

bimap id id ≡ id

If you supply first and second, ensure:

first id ≡ id
second id ≡ id

If you supply both, you should also ensure:

bimap f g ≡ first f . second g

These ensure by parametricity:

bimap  (f . g) (h . i) ≡ bimap f h . bimap g i
first  (f . g) ≡ first  f . first  g
second (f . g) ≡ second f . second g

Methods

  • bimap :: (a -> b) -> (c -> d) -> p a c -> p b d

    Map over both arguments at the same time.

    bimap f g ≡ first f . second g
    Examples
    Example1 expression
    bimap toUpper (+1) ('j', 3)('J',4)
    Example1 expression
    bimap toUpper (+1) (Left 'j')Left 'J'
    Example1 expression
    bimap toUpper (+1) (Right 3)Right 4
  • first :: (a -> b) -> p a c -> p b c

    Map covariantly over the first argument.

    first f ≡ bimap f id
    Examples
    Example1 expression
    first toUpper ('j', 3)('J',3)
    Example1 expression
    first toUpper (Left 'j')Left 'J'
  • second :: (b -> c) -> p a b -> p a c

    Map covariantly over the second argument.

    second ≡ bimap id
    Examples
    Example1 expression
    second (+1) ('j', 3)('j',4)
    Example1 expression
    second (+1) (Right 3)Right 4
Instances10Bifunctor, …
  • Bifunctor ArgDefined in base-4.20.2.0 · Data.Semigroup
  • Bifunctor EitherDefined in base-4.20.2.0 · Data.Bifunctor
  • Bifunctor Tuple2Defined in base-4.20.2.0 · Data.Bifunctor

    Class laws for tuples hold only up to laziness. Both first id and second id are lazier than id (and fmap id):

    Example3 expressions
    first id (undefined :: (Int, Word)) `seq` ()()second id (undefined :: (Int, Word)) `seq` ()()id (undefined :: (Int, Word)) `seq` ()*** Exception: Prelude.undefined
  • Bifunctor ConstDefined in base-4.20.2.0 · Data.Bifunctor
  • Bifunctor (Tuple3 x1)Defined in base-4.20.2.0 · Data.Bifunctor
  • Bifunctor (K1 i)Defined in base-4.20.2.0 · Data.Bifunctor
  • Bifunctor (Tuple4 x1 x2)Defined in base-4.20.2.0 · Data.Bifunctor
  • Bifunctor (Tuple5 x1 x2 x3)Defined in base-4.20.2.0 · Data.Bifunctor
  • Bifunctor (Tuple6 x1 x2 x3 x4)Defined in base-4.20.2.0 · Data.Bifunctor
  • Bifunctor (Tuple7 x1 x2 x3 x4 x5)Defined in base-4.20.2.0 · Data.Bifunctor
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.

Instances70Applicative, …
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.

Instances60Monad, …
  • 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 GenDefined in foundation-0.0.30 · Foundation.Check.Gen
  • Monad CheckMainDefined in foundation-0.0.30 · Foundation.Check.Main
  • Monad CheckDefined in foundation-0.0.30 · Foundation.Check.Types
  • Monad DListDefined in foundation-0.0.30 · Foundation.List.DList
  • Monad PartialDefined in foundation-0.0.30 · Foundation.Partial
  • Monad TimingPlanDefined in foundation-0.0.30 · Foundation.Timing.Main
  • 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 []Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • ParserSource input => Monad (Parser input)Defined in foundation-0.0.30 · Foundation.Parser
  • Monad ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Monad U1Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monad (MonadRandomState gen)Defined in foundation-0.0.30 · Foundation.Random.DRG
  • 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 (ResourceT m)Defined in foundation-0.0.30 · Foundation.Conduit.Internal
  • Monad m => Monad (IdentityT m)Defined in foundation-0.0.30 · Foundation.Monad.Identity
  • 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 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 (Reader r m)Defined in basement-0.0.16 · Basement.Compat.MonadTrans
  • Monad m => Monad (State r m)Defined in basement-0.0.16 · Basement.Compat.MonadTrans
  • Monad m => Monad (ExceptT e m)Defined in foundation-0.0.30 · Foundation.Monad.Except
  • Monad m => Monad (ReaderT r m)Defined in foundation-0.0.30 · Foundation.Monad.Reader
  • 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
  • (Functor m, Monad m) => Monad (StateT s m)Defined in foundation-0.0.30 · Foundation.Monad.State
  • (Monoid a, Monoid b) => Monad (Tuple3 a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monad (Conduit i o m)Defined in foundation-0.0.30 · Foundation.Conduit.Internal
  • 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 state => Monad (Builder collection mutCollection step state err)Defined in basement-0.0.16 · Basement.MutableBuilder
  • (Functor m, Monad m) => Monad (Pipe l i o u m)Defined in foundation-0.0.30 · Foundation.Conduit.Internal
value(=<<) :: Monad m => (a -> m b) -> m a -> m b
#

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

as >>= f == f =<< as
classclass IsString a where
#

IsString is used in combination with the -XOverloadedStrings language extension to convert the literals to different string types.

For example, if you use the text package, you can say

{-# LANGUAGE OverloadedStrings  #-}

myText = "hello world" :: Text

Internally, the extension will convert this to the equivalent of

myText = fromString @Text ("hello world" :: String)

Note: You can use fromString in normal code as well, but the usual performance/memory efficiency problems with String apply.

Methods

Instances9IsString, …
  • IsString AsciiStringDefined in basement-0.0.16 · Basement.Types.AsciiString
  • IsString StringDefined in basement-0.0.16 · Basement.UTF8.Base
  • IsString IPv4Defined in foundation-0.0.30 · Foundation.Network.IPv4
  • IsString IPv6Defined in foundation-0.0.30 · Foundation.Network.IPv6
  • IsString FileNameDefined in foundation-0.0.30 · Foundation.VFS.FilePath
  • IsString FilePathDefined in foundation-0.0.30 · Foundation.VFS.FilePath
  • IsString a => IsString (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.String
  • a ~ Char => IsString [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.String

    (a ~ Char) context was introduced in 4.9.0.0

  • IsString a => IsString (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.String
classclass IsList l where
#

The IsList class and its methods are intended to be used in conjunction with the OverloadedLists extension.

Associated types

  • type family Item l

    The Item type function returns the type of items of the structure l.

Methods

  • fromList :: [Item l] -> l

    The fromList function constructs the structure l from the given list of Item l

  • fromListN :: Int -> [Item l] -> l

    The fromListN function takes the input list's length and potentially uses it to construct the structure l more efficiently compared to fromList. If the given number does not equal to the input list's length the behaviour of fromListN is not specified.

    Property
    fromListN (length xs) xs == fromList xs
  • toList :: l -> [Item l]

    The toList function extracts a list of Item l from the structure l. It should satisfy fromList . toList = id.

Instances17IsList, …
  • IsList ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • IsList AsciiStringDefined in basement-0.0.16 · Basement.Types.AsciiString
  • IsList StringDefined in basement-0.0.16 · Basement.UTF8.Base
  • IsList BitmapDefined in foundation-0.0.30 · Foundation.Array.Bitmap
  • IsList CSVDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • IsList RowDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • IsList VersionDefined in ghc-internal-9.1003.0 · GHC.Internal.IsList
  • IsList CallStackDefined in ghc-internal-9.1003.0 · GHC.Internal.IsList

    Be aware that 'fromList . toList = id' only for unfrozen CallStacks, since toList removes frozenness information.

  • PrimType ty => IsList (Block ty)Defined in basement-0.0.16 · Basement.Block.Base
  • PrimType ty => IsList (UArray ty)Defined in basement-0.0.16 · Basement.UArray.Base
  • PrimType ty => IsList (ChunkedUArray ty)Defined in foundation-0.0.30 · Foundation.Array.Chunked.Unboxed
  • IsList (Array ty)Defined in basement-0.0.16 · Basement.BoxedArray
  • IsList (DList a)Defined in foundation-0.0.30 · Foundation.List.DList
  • IsList (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.IsList
  • IsList (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.IsList
  • IsList [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.IsList
  • IsList c => IsList (NonEmpty c)Defined in basement-0.0.16 · Basement.NonEmpty

Numeric type classes

classclass (Integral a, Eq a, Ord a) => IsIntegral a where
#

Number literals, convertible through the generic Integer type.

all number are Enum'erable, meaning that you can move to next element

Methods

Instances38IsIntegral, …
classclass IsIntegral a => IsNatural a where
#

Non Negative Number literals, convertible through the generic Natural type

Methods

Instances20IsNatural, …
classclass Signed a where
#

types that have sign and can be made absolute

Methods

Instances8Signed, …
  • Signed IntegerDefined in foundation-0.0.30 · Foundation.Numerical
  • Signed Int16Defined in foundation-0.0.30 · Foundation.Numerical
  • Signed Int32Defined in foundation-0.0.30 · Foundation.Numerical
  • Signed Int64Defined in foundation-0.0.30 · Foundation.Numerical
  • Signed Int8Defined in foundation-0.0.30 · Foundation.Numerical
  • Signed DoubleDefined in foundation-0.0.30 · Foundation.Numerical
  • Signed FloatDefined in foundation-0.0.30 · Foundation.Numerical
  • Signed IntDefined in foundation-0.0.30 · Foundation.Numerical
classclass Additive a where
#

Represent class of things that can be added together, contains a neutral element and is commutative.

x + azero = x
azero + x = x
x + y = y + x

Methods

Instances50Additive, …
classclass Subtractive a where
#

Represent class of things that can be subtracted.

Note that the result is not necessary of the same type as the operand depending on the actual type.

For example:

(-) :: Int -> Int -> Int
(-) :: DateTime -> DateTime -> Seconds
(-) :: Ptr a -> Ptr a -> PtrDiff
(-) :: Natural -> Natural -> Maybe Natural

Associated types

Methods

Instances49Subtractive, …
classclass Multiplicative a where
#

Represent class of things that can be multiplied together

x * midentity = x
midentity * x = x

Methods

  • midentity :: a

    Identity element over multiplication

  • (*) :: a -> a -> ainfixl 7

    Multiplication of 2 elements that result in another element

  • (^) :: (IsNatural n, Enum n, IDivisible n) => a -> n -> ainfixr 8

    Raise to power, repeated multiplication e.g. > a ^ 2 = a * a > a ^ 10 = (a ^ 5) * (a ^ 5) .. (^) :: (IsNatural n) => a -> n -> a

Instances44Multiplicative, …
classclass (Additive a, Multiplicative a) => IDivisible a where
#

Represent types that supports an euclidian division

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

Methods

  • div :: a -> a -> a
  • mod :: a -> a -> a
  • divMod :: a -> a -> (a, a)
Instances34IDivisible, …
  • IDivisible Word128Defined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible Word256Defined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible IntegerDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible NaturalDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CCharDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CIntDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CIntMaxDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CIntPtrDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CLLongDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CLongDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CPtrdiffDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CSCharDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CShortDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CSigAtomicDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CSizeDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CUCharDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CUIntDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CUIntMaxDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CUIntPtrDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CULLongDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CULongDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CUShortDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible CWcharDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible Int16Defined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible Int32Defined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible Int64Defined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible Int8Defined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible Word16Defined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible Word32Defined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible Word64Defined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible Word8Defined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible IntDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • IDivisible WordDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • SizeValid n => IDivisible (Bits n)Defined in basement-0.0.16 · Basement.Bits
classclass Multiplicative a => Divisible a where
#

Support for division between same types

This is likely to change to represent specific mathematic divisions

Methods

  • (/) :: a -> a -> ainfixl 7
Instances5Divisible
  • Divisible CDoubleDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • Divisible CFloatDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • Divisible RationalDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • Divisible DoubleDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • Divisible FloatDefined in basement-0.0.16 · Basement.Numerical.Multiplicative

Data types

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

Instances36Monad, Functor, MonadFix, MonadFail, Applicative, Foldable, …
datadata Ordering
#
Instances12Bounded, Enum, Eq, Data, Ord, Read, …
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
  • BitOps BoolDefined in basement-0.0.16 · Basement.Bits
  • FiniteBitsOps BoolDefined in basement-0.0.16 · Basement.Bits
  • NormalForm BoolDefined in basement-0.0.16 · Basement.NormalForm
  • Arbitrary BoolDefined in foundation-0.0.30 · Foundation.Check.Arbitrary
  • IsProperty BoolDefined in foundation-0.0.30 · Foundation.Check.Property
  • IsField BoolDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • SingI 'FalseDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • SingI 'TrueDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • IsProperty (String, Bool)Defined in foundation-0.0.30 · Foundation.Check.Property
  • 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.

Instances37Bounded, Enum, Data, Read, Ix, IsChar, …
newtypenewtype Char7
#

ASCII value between 0x0 and 0x7f

Instances8Eq, Ord, Show, PrimType, NormalForm, Arbitrary, …
  • Eq Char7Defined in basement-0.0.16 · Basement.Types.Char7
  • Ord Char7Defined in basement-0.0.16 · Basement.Types.Char7
  • Show Char7Defined in basement-0.0.16 · Basement.Types.Char7
  • PrimType Char7Defined in basement-0.0.16 · Basement.PrimType
  • NormalForm Char7Defined in basement-0.0.16 · Basement.NormalForm
  • Arbitrary Char7Defined in foundation-0.0.30 · Foundation.Check.Arbitrary
  • type NatNumMaxBound Char7 = 127Defined in basement-0.0.16 · Basement.Nat
  • type PrimSize Char7 = 1Defined in basement-0.0.16 · Basement.PrimType
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.

Instances20Monad, Functor, MonadFix, MonadFail, Applicative, GHCiSandboxIO, …
  • Monad IODefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Functor IODefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • MonadFix IODefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Monad.Fix
  • MonadFail IODefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Monad.Fail
  • Applicative IODefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • GHCiSandboxIO IODefined in ghc-internal-9.1003.0 · GHC.Internal.GHCi
  • Alternative IODefined in ghc-internal-9.1003.0 · GHC.Internal.Base

    Takes the first non-throwing IO action's result. empty throws an exception.

  • MonadPlus IODefined in ghc-internal-9.1003.0 · GHC.Internal.Base

    Takes the first non-throwing IO action's result. mzero throws an exception.

  • MonadIO IODefined in base-4.20.2.0 · Control.Monad.IO.Class
  • PrimMonad IODefined in basement-0.0.16 · Basement.Monad
  • MonadThrow IODefined in foundation-0.0.30 · Foundation.Monad.Exception
  • MonadBracket IODefined in foundation-0.0.30 · Foundation.Monad.Exception
  • MonadCatch IODefined in foundation-0.0.30 · Foundation.Monad.Exception
  • MonadRandom IODefined in foundation-0.0.30 · Foundation.Random.Class
  • Semigroup a => Semigroup (IO a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid a => Monoid (IO a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • a ~ () => HPrintfType (IO a)Defined in base-4.20.2.0 · Text.Printf
  • a ~ () => PrintfType (IO a)Defined in base-4.20.2.0 · Text.Printf
  • type PrimState IO = RealWorldDefined in basement-0.0.16 · Basement.Monad
  • type PrimVar IO = IORefDefined in basement-0.0.16 · Basement.Monad
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

Instances34Bifoldable, Bifoldable1, Bifunctor, Bitraversable, Eq2, Ord2, …

Numbers

datadata Int8
#

8-bit signed integer type

Instances49Bounded, Enum, Eq, Data, Num, Ord, …
datadata Int16
#

16-bit signed integer type

Instances51Bounded, Enum, Eq, Data, Num, Ord, …
datadata Int32
#

32-bit signed integer type

Instances52Bounded, Enum, Eq, Data, Num, Ord, …
datadata Int64
#

64-bit signed integer type

Instances59Bounded, Enum, Eq, Data, Num, Ord, …
datadata Word8
#

8-bit unsigned integer type

Instances70Bounded, Enum, Eq, Data, Num, Ord, …
datadata Word16
#

16-bit unsigned integer type

Instances64Bounded, Enum, Eq, Data, Num, Ord, …
datadata Word32
#

32-bit unsigned integer type

Instances63Bounded, Enum, Eq, Data, Num, Ord, …
datadata Word64
#

64-bit unsigned integer type

Instances66Bounded, Enum, Eq, Data, Num, Ord, …
datadata Word
#

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

Instances64Bounded, Enum, Data, Num, Read, Real, …
datadata Word128
#

128 bits Word

Instances40Bounded, Enum, Eq, Num, Ord, Show, …
datadata Word256
#

256 bits Word

Instances40Bounded, Enum, Eq, Num, Ord, Show, …
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.

Instances67Bounded, Enum, Data, Num, Read, Real, …
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.

Instances36Enum, Eq, Data, Num, Ord, Read, …
datadata Natural
#

Natural number

Invariant: numbers <= 0xffffffffffffffff use the NS constructor

Instances34Enum, Eq, Data, Num, Ord, Read, …
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.

Instances5Additive, Multiplicative, Fractional, Divisible, IntegralRounding
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.

Instances43Enum, Floating, Data, Num, Read, Real, …
  • 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
  • Integral FloatDefined in basement-0.0.16 · Basement.Compat.NumLiteral
  • Additive FloatDefined in basement-0.0.16 · Basement.Numerical.Additive
  • Multiplicative FloatDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • Subtractive FloatDefined in basement-0.0.16 · Basement.Numerical.Subtractive
  • PrimType FloatDefined in basement-0.0.16 · Basement.PrimType
  • NormalForm FloatDefined in basement-0.0.16 · Basement.NormalForm
  • Fractional FloatDefined in basement-0.0.16 · Basement.Compat.NumLiteral
  • HasNegation FloatDefined in basement-0.0.16 · Basement.Compat.NumLiteral
  • Divisible FloatDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • Signed FloatDefined in foundation-0.0.30 · Foundation.Numerical
  • Arbitrary FloatDefined in foundation-0.0.30 · Foundation.Check.Arbitrary
  • Storable FloatDefined in foundation-0.0.30 · Foundation.Class.Storable
  • StorableFixed FloatDefined in foundation-0.0.30 · Foundation.Class.Storable
  • Trigonometry FloatDefined in foundation-0.0.30 · Foundation.Math.Trigonometry
  • IntegralRounding FloatDefined in foundation-0.0.30 · Foundation.Numerical
  • FloatingPoint FloatDefined in foundation-0.0.30 · Foundation.Numerical.Floating
  • 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
  • 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#

  • type Difference Float = FloatDefined in basement-0.0.16 · Basement.Numerical.Subtractive
  • type PrimSize Float = 4Defined in basement-0.0.16 · Basement.PrimType
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.

Instances44Enum, Floating, Data, Num, Read, Real, …
  • 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
  • Integral DoubleDefined in basement-0.0.16 · Basement.Compat.NumLiteral
  • Additive DoubleDefined in basement-0.0.16 · Basement.Numerical.Additive
  • Multiplicative DoubleDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • Subtractive DoubleDefined in basement-0.0.16 · Basement.Numerical.Subtractive
  • PrimType DoubleDefined in basement-0.0.16 · Basement.PrimType
  • NormalForm DoubleDefined in basement-0.0.16 · Basement.NormalForm
  • Fractional DoubleDefined in basement-0.0.16 · Basement.Compat.NumLiteral
  • HasNegation DoubleDefined in basement-0.0.16 · Basement.Compat.NumLiteral
  • Divisible DoubleDefined in basement-0.0.16 · Basement.Numerical.Multiplicative
  • Signed DoubleDefined in foundation-0.0.30 · Foundation.Numerical
  • Arbitrary DoubleDefined in foundation-0.0.30 · Foundation.Check.Arbitrary
  • Storable DoubleDefined in foundation-0.0.30 · Foundation.Class.Storable
  • StorableFixed DoubleDefined in foundation-0.0.30 · Foundation.Class.Storable
  • IsField DoubleDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • Trigonometry DoubleDefined in foundation-0.0.30 · Foundation.Math.Trigonometry
  • IntegralRounding DoubleDefined in foundation-0.0.30 · Foundation.Numerical
  • FloatingPoint DoubleDefined in foundation-0.0.30 · Foundation.Numerical.Floating
  • 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
  • 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#

  • type Difference Double = DoubleDefined in basement-0.0.16 · Basement.Numerical.Subtractive
  • type PrimSize Double = 8Defined in basement-0.0.16 · Basement.PrimType
newtypenewtype CountOf ty
#

CountOf of a data structure.

More specifically, it represents the number of elements of type ty that fit into the data structure.

Example1 expression
length (fromList ['a', 'b', 'c', '🌟']) :: CountOf CharCountOf 4

Same caveats as Offset apply here.

Constructors

Instances21TryFrom, Enum, Eq, Num, Ord, Show, …
newtypenewtype Offset ty
#

Offset in a data structure consisting of elements of type ty.

Int is a terrible backing type which is hard to get away from, considering that GHC/Haskell are mostly using this for offset. Trying to bring some sanity by a lightweight wrapping.

Constructors

Instances16From, TryFrom, Enum, Eq, Num, Ord, …
  • From Word (Offset ty)Defined in basement-0.0.16 · Basement.From
  • TryFrom Int (Offset ty)Defined in basement-0.0.16 · Basement.From
  • Enum (Offset ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • Eq (Offset ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • Num (Offset ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • Ord (Offset ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • Show (Offset ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • Integral (Offset ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • Additive (Offset ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • IsNatural (Offset ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • Subtractive (Offset ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • IsIntegral (Offset ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • NormalForm (Offset a)Defined in basement-0.0.16 · Basement.NormalForm
  • IsField (Offset a)Defined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • type Difference (Offset ty) = CountOf tyDefined in basement-0.0.16 · Basement.Types.OffsetSize
  • type NatNumMaxBound (Offset x) = NatNumMaxBound IntDefined in basement-0.0.16 · Basement.Types.OffsetSize

Collection types

datadata UArray ty
#

An array of type built on top of GHC primitive.

The elements need to have fixed sized and the representation is a packed contiguous array in memory that can easily be passed to foreign interface

Instances31IsList, Eq, Data, Ord, Show, Semigroup, …
classclass Eq ty => PrimType ty where
#

Represent the accessor for types that can be stored in the UArray and MUArray.

Types need to be a instance of storable and have fixed sized.

Instances22PrimType, …
datadata Array a
#

Array of a

Instances30Functor, Mappable, IsList, Eq, Data, Ord, …
newtypenewtype String
#

Opaque packed array of characters in the UTF8 encoding

Instances30IsList, Eq, Data, Ord, IsString, Semigroup, …

Numeric functions

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.

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

Monoids

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)

Instances78Semigroup, …
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!"
Instances69Monoid, …
  • Monoid ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • Monoid BuilderDefined in basement-0.0.16 · Basement.Block.Builder
  • Monoid BuilderDefined in basement-0.0.16 · Basement.String.Builder
  • Monoid AsciiStringDefined in basement-0.0.16 · Basement.Types.AsciiString
  • Monoid StringDefined in basement-0.0.16 · Basement.UTF8.Base
  • Monoid BitmapDefined in foundation-0.0.30 · Foundation.Array.Bitmap
  • Monoid CSVDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • Monoid RowDefined in foundation-0.0.30 · Foundation.Format.CSV.Types
  • Monoid FileNameDefined in foundation-0.0.30 · Foundation.VFS.FilePath
  • 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 ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • PrimType ty => Monoid (Block ty)Defined in basement-0.0.16 · Basement.Block.Base
  • PrimType ty => Monoid (UArray ty)Defined in basement-0.0.16 · Basement.UArray.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 (Array a)Defined in basement-0.0.16 · Basement.BoxedArray
  • Monoid (CountOf ty)Defined in basement-0.0.16 · Basement.Types.OffsetSize
  • Monoid (ChunkedUArray a)Defined in foundation-0.0.30 · Foundation.Array.Chunked.Unboxed
  • Monoid (DList a)Defined in foundation-0.0.30 · Foundation.List.DList
  • 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 [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 (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
  • (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
method(<>) :: a -> a -> a
#

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!

Collection

classclass (IsList c, Item c ~ Element c) => Collection c where
#

A set of methods for ordered colection

Methods

Instances12Collection, …
classclass (IsList c, Item c ~ Element c, Monoid c, Collection c) => Sequential c where
#

A set of methods for ordered colection

Methods

  • take :: CountOf (Element c) -> c -> c

    Take the first @n elements of a collection

  • revTake :: CountOf (Element c) -> c -> c

    Take the last @n elements of a collection

  • drop :: CountOf (Element c) -> c -> c

    Drop the first @n elements of a collection

  • revDrop :: CountOf (Element c) -> c -> c

    Drop the last @n elements of a collection

  • splitAt :: CountOf (Element c) -> c -> (c, c)

    Split the collection at the @n'th elements

  • revSplitAt :: CountOf (Element c) -> c -> (c, c)

    Split the collection at the @n'th elements from the end

  • splitOn :: (Element c -> Bool) -> c -> [c]

    Split on a specific elements returning a list of colletion

  • break :: (Element c -> Bool) -> c -> (c, c)

    Split a collection when the predicate return true

  • breakEnd :: (Element c -> Bool) -> c -> (c, c)

    Split a collection when the predicate return true starting from the end of the collection

  • breakElem :: Eq (Element c) => Element c -> c -> (c, c)

    Split a collection at the given element

  • takeWhile :: (Element c -> Bool) -> c -> c

    Return the longest prefix in the collection that satisfy the predicate

  • dropWhile :: (Element c -> Bool) -> c -> c

    Return the longest prefix in the collection that satisfy the predicate

  • intersperse :: Element c -> c -> c

    The intersperse function takes an element and a list and `intersperses' that element between the elements of the list. For example,

    intersperse ',' "abcde" == "a,b,c,d,e"
  • intercalate :: Monoid (Item c) => Element c -> c -> Element c

    intercalate xs xss is equivalent to (mconcat (intersperse xs xss)). It inserts the list xs in between the lists in xss and concatenates the result.

  • span :: (Element c -> Bool) -> c -> (c, c)

    Split a collection while the predicate return true

  • spanEnd :: (Element c -> Bool) -> c -> (c, c)

    Split a collection while the predicate return true starting from the end of the collection

  • filter :: (Element c -> Bool) -> c -> c

    Filter all the elements that satisfy the predicate

  • partition :: (Element c -> Bool) -> c -> (c, c)

    Partition the elements that satisfy the predicate and those that don't

  • reverse :: c -> c

    Reverse a collection

  • uncons :: c -> Maybe (Element c, c)

    Decompose a collection into its first element and the remaining collection. If the collection is empty, returns Nothing.

  • unsnoc :: c -> Maybe (c, Element c)

    Decompose a collection into a collection without its last element, and the last element If the collection is empty, returns Nothing.

  • snoc :: c -> Element c -> c

    Prepend an element to an ordered collection

  • cons :: Element c -> c -> c

    Append an element to an ordered collection

  • find :: (Element c -> Bool) -> c -> Maybe (Element c)

    Find an element in an ordered collection

  • sortBy :: (Element c -> Element c -> Ordering) -> c -> c

    Sort an ordered collection using the specified order function

  • singleton :: Element c -> c

    Create a collection with a single element

  • head :: NonEmpty c -> Element c

    get the first element of a non-empty collection

  • last :: NonEmpty c -> Element c

    get the last element of a non-empty collection

  • tail :: NonEmpty c -> c

    Extract the elements after the first element of a non-empty collection.

  • init :: NonEmpty c -> c

    Extract the elements before the last element of a non-empty collection.

  • replicate :: CountOf (Element c) -> Element c -> c

    Create a collection where the element in parameter is repeated N time

  • isPrefixOf :: Eq (Element c) => c -> c -> Bool

    Takes two collections and returns True iff the first collection is a prefix of the second.

  • isSuffixOf :: Eq (Element c) => c -> c -> Bool

    Takes two collections and returns True iff the first collection is a suffix of the second.

  • isInfixOf :: Eq (Element c) => c -> c -> Bool

    Takes two collections and returns True iff the first collection is an infix of the second.

  • stripPrefix :: Eq (Element c) => c -> c -> Maybe c

    Try to strip a prefix from a collection

  • stripSuffix :: Eq (Element c) => c -> c -> Maybe c

    Try to strip a suffix from a collection

Instances11Sequential, …
newtypenewtype NonEmpty a
#

NonEmpty property for any Collection

Instances6IsList, Eq, Show, Collection, Item, Element
valuenonEmpty :: Collection c => c -> Maybe (NonEmpty c)
#

Smart constructor to create a NonEmpty collection

If the collection is empty, then Nothing is returned Otherwise, the collection is wrapped in the NonEmpty property

Folds

classclass Foldable collection where
#

Give the ability to fold a collection on itself

Methods

  • foldl' :: (a -> Element collection -> a) -> a -> collection -> a

    Left-associative fold of a structure.

    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. This means that foldl' will diverge if given an infinite list.

    Note that Foundation only provides foldl', a strict version of foldl because the lazy version is seldom useful.

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

  • foldr :: (Element collection -> a -> a) -> a -> collection -> a

    Right-associative fold of a structure.

    foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
  • foldr' :: (Element collection -> a -> a) -> a -> collection -> a

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

Instances9Foldable, …
  • Foldable BitmapDefined in foundation-0.0.30 · Foundation.Array.Bitmap
  • PrimType ty => Foldable (Block ty)Defined in foundation-0.0.30 · Foundation.Collection.Foldable
  • PrimType ty => Foldable (UArray ty)Defined in foundation-0.0.30 · Foundation.Collection.Foldable
  • PrimType ty => Foldable (ChunkedUArray ty)Defined in foundation-0.0.30 · Foundation.Array.Chunked.Unboxed
  • Foldable (Array ty)Defined in foundation-0.0.30 · Foundation.Collection.Foldable
  • Foldable (DList a)Defined in foundation-0.0.30 · Foundation.List.DList
  • Foldable [a]Defined in foundation-0.0.30 · Foundation.Collection.Foldable
  • PrimType ty => Foldable (BlockN n ty)Defined in foundation-0.0.30 · Foundation.Collection.Foldable
  • Foldable (ListN n a)Defined in foundation-0.0.30 · Foundation.Collection.Foldable

Maybe

valuemapMaybe :: (a -> Maybe b) -> [a] -> [b]
#

The mapMaybe function is a version of map which can throw out elements. In particular, the functional argument returns something of type Maybe b. If this is Nothing, no element is added on to the result list. If it is Just b, then b is included in the result list.

Examples

Using mapMaybe f x is a shortcut for catMaybes $ map f x in most cases:

Example4 expressions
import GHC.Internal.Text.Read ( readMaybe )let readMaybeInt = readMaybe :: String -> Maybe IntmapMaybe readMaybeInt ["1", "Foo", "3"][1,3]catMaybes $ map readMaybeInt ["1", "Foo", "3"][1,3]

If we map the Just constructor, the entire list should be returned:

Example1 expression
mapMaybe Just [1,2,3][1,2,3]
valuecatMaybes :: [Maybe a] -> [a]
#

The catMaybes function takes a list of Maybes and returns a list of all the Just values.

Examples

Basic usage:

Example1 expression
catMaybes [Just 1, Nothing, Just 3][1,3]

When constructing a list of Maybe values, catMaybes can be used to return all of the "success" results (if the list is the result of a map, then mapMaybe would be more appropriate):

Example3 expressions
import GHC.Internal.Text.Read ( readMaybe )[readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ][Just 1,Nothing,Just 3]catMaybes $ [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ][1,3]
valuefromMaybe :: a -> Maybe a -> a
#

The fromMaybe function takes a default value and a Maybe value. If the Maybe is Nothing, it returns the default value; otherwise, it returns the value contained in the Maybe.

Examples

Basic usage:

Example1 expression
fromMaybe "" (Just "Hello, World!")"Hello, World!"
Example1 expression
fromMaybe "" Nothing""

Read an integer from a string using readMaybe. If we fail to parse an integer, we want to return 0 by default:

Example3 expressions
import GHC.Internal.Text.Read ( readMaybe )fromMaybe 0 (readMaybe "5")5fromMaybe 0 (readMaybe "")0
valueisJust :: Maybe a -> Bool
#

The isJust function returns True iff its argument is of the form Just _.

Examples

Basic usage:

Example1 expression
isJust (Just 3)True
Example1 expression
isJust (Just ())True
Example1 expression
isJust NothingFalse

Only the outer constructor is taken into consideration:

Example1 expression
isJust (Just Nothing)True
valueisNothing :: Maybe a -> Bool
#

The isNothing function returns True iff its argument is Nothing.

Examples

Basic usage:

Example1 expression
isNothing (Just 3)False
Example1 expression
isNothing (Just ())False
Example1 expression
isNothing NothingTrue

Only the outer constructor is taken into consideration:

Example1 expression
isNothing (Just Nothing)False
valuelistToMaybe :: [a] -> Maybe a
#

The listToMaybe function returns Nothing on an empty list or Just a where a is the first element of the list.

Examples

Basic usage:

Example1 expression
listToMaybe []Nothing
Example1 expression
listToMaybe [9]Just 9
Example1 expression
listToMaybe [1,2,3]Just 1

Composing maybeToList with listToMaybe should be the identity on singleton/empty lists:

Example2 expressions
maybeToList $ listToMaybe [5][5]maybeToList $ listToMaybe [][]

But not on lists with more than one element:

Example1 expression
maybeToList $ listToMaybe [1,2,3][1]
valuemaybeToList :: Maybe a -> [a]
#

The maybeToList function returns an empty list when given Nothing or a singleton list when given Just.

Examples

Basic usage:

Example1 expression
maybeToList (Just 7)[7]
Example1 expression
maybeToList Nothing[]

One can use maybeToList to avoid pattern matching when combined with a function that (safely) works on lists:

Example3 expressions
import GHC.Internal.Text.Read ( readMaybe )sum $ maybeToList (readMaybe "3")3sum $ maybeToList (readMaybe "")0

Either

valuepartitionEithers :: [Either a b] -> ([a], [b])
#

Partitions a list of Either into two lists. All the Left elements are extracted, in order, to the first component of the output. Similarly the Right elements are extracted to the second component of the output.

Examples

Basic usage:

Example2 expressions
let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]partitionEithers list(["foo","bar","baz"],[3,7])

The pair returned by partitionEithers x should be the same pair as (lefts x, rights x):

Example2 expressions
let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]partitionEithers list == (lefts list, rights list)True
valuelefts :: [Either a b] -> [a]
#

Extracts from a list of Either all the Left elements. All the Left elements are extracted in order.

Examples

Basic usage:

Example2 expressions
let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]lefts list["foo","bar","baz"]
valuerights :: [Either a b] -> [b]
#

Extracts from a list of Either all the Right elements. All the Right elements are extracted in order.

Examples

Basic usage:

Example2 expressions
let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]rights list[3,7]

Function

valueon :: (b -> b -> c) -> (a -> b) -> a -> a -> c
#

on b u x y runs the binary function b on the results of applying unary function u to two arguments x and y. From the opposite perspective, it transforms two inputs and combines the outputs.

(op `on` f) x y = f x `op` f y
Examples
Example1 expression
sortBy (compare `on` length) [[0, 1, 2], [0, 1], [], [0]][[],[0],[0,1],[0,1,2]]
Example1 expression
((+) `on` length) [1, 2, 3] [-1]4
Example1 expression
((,) `on` (*2)) 2 3(4,6)
Algebraic properties
  • (*) `on` id = (*) -- (if (*) ∉ {⊥, const ⊥})
  • ((*) `on` f) `on` g = (*) `on` (f . g)
  • flip on f . flip on g = flip on (g . f)

Applicative

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)
method(<|>) :: f a -> f a -> f a
#

An associative binary operation

Monad

value(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
#

Left-to-right composition of Kleisli arrows.

'(bs >=> cs) a' can be understood as the do expression

do b <- bs a
   cs b

or in terms of (>>=) as

bs a >>= cs

Exceptions

classclass (Typeable e, Show e) => Exception e where
#

Any type that you wish to throw or catch as an exception must be an instance of the Exception class. The simplest case is a new exception type directly below the root:

data MyException = ThisException | ThatException
    deriving Show

instance Exception MyException

The default method definitions in the Exception class do what we need in this case. You can now throw and catch ThisException and ThatException as exceptions:

*Main> throw ThisException `catch` \e -> putStrLn ("Caught " ++ show (e :: MyException))
Caught ThisException

In more complicated examples, you may wish to define a whole hierarchy of exceptions:

---------------------------------------------------------------------
-- Make the root exception type for all the exceptions in a compiler

data SomeCompilerException = forall e . Exception e => SomeCompilerException e

instance Show SomeCompilerException where
    show (SomeCompilerException e) = show e

instance Exception SomeCompilerException

compilerExceptionToException :: Exception e => e -> SomeException
compilerExceptionToException = toException . SomeCompilerException

compilerExceptionFromException :: Exception e => SomeException -> Maybe e
compilerExceptionFromException x = do
    SomeCompilerException a <- fromException x
    cast a

---------------------------------------------------------------------
-- Make a subhierarchy for exceptions in the frontend of the compiler

data SomeFrontendException = forall e . Exception e => SomeFrontendException e

instance Show SomeFrontendException where
    show (SomeFrontendException e) = show e

instance Exception SomeFrontendException where
    toException = compilerExceptionToException
    fromException = compilerExceptionFromException

frontendExceptionToException :: Exception e => e -> SomeException
frontendExceptionToException = toException . SomeFrontendException

frontendExceptionFromException :: Exception e => SomeException -> Maybe e
frontendExceptionFromException x = do
    SomeFrontendException a <- fromException x
    cast a

---------------------------------------------------------------------
-- Make an exception type for a particular frontend compiler exception

data MismatchedParentheses = MismatchedParentheses
    deriving Show

instance Exception MismatchedParentheses where
    toException   = frontendExceptionToException
    fromException = frontendExceptionFromException

We can now catch a MismatchedParentheses exception as MismatchedParentheses, SomeFrontendException or SomeCompilerException, but not other types, e.g. IOException:

*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeFrontendException))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeCompilerException))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: IOException))
*** Exception: MismatchedParentheses

Methods

Instances44Exception, …
classclass Typeable (a :: k) where
#

The class Typeable allows a concrete representation of a type to be calculated.

datadata SomeException
#

The SomeException type is the root of the exception type hierarchy. When an exception of type e is thrown, behind the scenes it is encapsulated in a SomeException.

Instances2Show, Exception
datadata IOException
#

Exceptions that occur in the IO monad. An IOException records a more specific error type, a descriptive string and maybe the handle that was used when the error was flagged.

Instances3Eq, Show, Exception

Proxy

datadata Proxy (t :: k)
#

Proxy is a type that holds no data, but has a phantom parameter of arbitrary type (or even kind). Its use is to provide type information, even though there is no value available of that type (or it may be too costly to create one).

Historically, Proxy :: Proxy a is a safer alternative to the undefined :: a idiom.

Example1 expression
Proxy :: Proxy (Void, Int -> Int)Proxy

Proxy can even hold types of higher kinds,

Example1 expression
Proxy :: Proxy EitherProxy
Example1 expression
Proxy :: Proxy FunctorProxy
Example1 expression
Proxy :: Proxy complicatedStructureProxy
Instances27Generic1, Monad, Functor, Applicative, Foldable, Traversable, …
  • Generic1 ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monad ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Functor ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Applicative ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Foldable ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Foldable
  • Traversable ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Traversable
  • Alternative ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • MonadPlus ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • MonadZip ProxyDefined in base-4.20.2.0 · Control.Monad.Zip
  • Eq1 ProxyDefined in base-4.20.2.0 · Data.Functor.Classes
  • Ord1 ProxyDefined in base-4.20.2.0 · Data.Functor.Classes
  • Read1 ProxyDefined in base-4.20.2.0 · Data.Functor.Classes
  • Show1 ProxyDefined in base-4.20.2.0 · Data.Functor.Classes
  • Contravariant ProxyDefined in base-4.20.2.0 · Data.Functor.Contravariant
  • Bounded (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Enum (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Eq (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Data t => Data (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Ord (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Read (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Show (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Ix (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Generic (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Semigroup (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Monoid (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • type Rep (Proxy t) = D1 ('MetaData "Proxy" "GHC.Internal.Data.Proxy" "ghc-internal" 'False) (C1 ('MetaCons "Proxy" 'PrefixI 'False) U1)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • type Rep1 Proxy = D1 ('MetaData "Proxy" "GHC.Internal.Data.Proxy" "ghc-internal" 'False) (C1 ('MetaCons "Proxy" 'PrefixI 'False) U1)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
valueasProxyTypeOf :: a -> proxy a -> a
#

asProxyTypeOf 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 tag of the second.

Example2 expressions
import GHC.Internal.Word:type asProxyTypeOf 123 (Proxy :: Proxy Word8)asProxyTypeOf 123 (Proxy :: Proxy Word8) :: Word8

Note the lower-case proxy in the definition. This allows any type constructor with just one argument to be passed to the function, for example we could also write

Example2 expressions
import GHC.Internal.Word:type asProxyTypeOf 123 (Just (undefined :: Word8))asProxyTypeOf 123 (Just (undefined :: Word8)) :: Word8

Partial

newtypenewtype Partial a
#

Partialiality wrapper.

Instances3Monad, Functor, Applicative
datadata PartialError
#

An error related to the evaluation of a Partial value that failed.

it contains the name of the function and the reason for failure

Instances3Eq, Show, Exception
valueifThenElse :: Bool -> a -> a -> a
#

for support of if .. then .. else

Old Prelude Strings as [Char] with bridge back and forth

typetype LString = String
#

Alias to Prelude String ([Char]) for compatibility purpose