HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulererebase-1.21.2Haskell2010

Prelude

  • 246 types
  • 109 classes
  • 1129 values
  • Packagererebase-1.21.2
  • Exports1504
  • LanguageHaskell2010
  • LicenceMIT
  • SourceDeepSeq.hs
valuedeepseq :: NFData a => a -> b -> b
#

deepseq: fully evaluates the first argument, before returning the second.

The name deepseq is used to illustrate the relationship to seq: where seq is shallow in the sense that it only evaluates the top level of its argument, deepseq traverses the entire data structure evaluating it completely.

deepseq can be useful for forcing pending exceptions, eradicating space leaks, or forcing lazy I/O to happen. It is also useful in conjunction with parallel Strategies (see the parallel package).

There is no guarantee about the ordering of evaluation. The implementation may evaluate the components of the structure in any order or in parallel. To impose an actual order on evaluation, use pseq from Control.Parallel in the parallel package.

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 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
valuevoid :: Functor f => f a -> f ()
#

void value discards or ignores the result of evaluation, such as the return value of an System.IO.IO action.

Examples

Replace the contents of a Maybe Int with unit:

Example1 expression
void NothingNothing
Example1 expression
void (Just 3)Just ()

Replace the contents of an Either Int Int with unit, resulting in an Either Int ():

Example1 expression
void (Left 8675309)Left 8675309
Example1 expression
void (Right 8675309)Right ()

Replace every element of a list with unit:

Example1 expression
void [1,2,3][(),(),()]

Replace the second element of a pair with unit:

Example1 expression
void (1,2)(1,())

Discard the result of an System.IO.IO action:

Example1 expression
mapM print [1,2]12[(),()]
Example1 expression
void $ mapM print [1,2]12
valuecases :: Eq a => [a] -> Cases a
#

Embed a list of values into Cases using the trivial but slow membership test based on elem.

valuegroup :: Eq a => [a] -> [[a]]
#

The group function takes a list and returns a list of lists such that the concatenation of the result is equal to the argument. Moreover, each sublist in the result is non-empty, all elements are equal to the first one, and consecutive equal elements of the input end up in the same element of the output list.

group is a special case of groupBy, which allows the programmer to supply their own equality test.

It's often preferable to use Data.List.NonEmpty.group, which provides type-level guarantees of non-emptiness of inner lists. A common idiom to squash repeating elements map head . group is better served by map Data.List.NonEmpty.head . Data.List.NonEmpty.group because it avoids partial functions.

Examples
Example1 expression
group "Mississippi"["M","i","ss","i","ss","i","pp","i"]
Example1 expression
group [1, 1, 1, 2, 2, 3, 4, 5, 5][[1,1,1],[2,2],[3],[4],[5,5]]
valuelabel :: MonadCont m => a -> m (a -> m b, a)
#

Introduces a recursive binding to the continuation. Due to the use of callCC, calling the continuation will interrupt execution of the current block creating an effect similar to goto/setjmp in C.

valueinterruptible :: IO a -> IO a
#

Allow asynchronous exceptions to be raised even inside mask, making the operation interruptible (see the discussion of "Interruptible operations" in Control.Exception).

When called outside mask, or inside uninterruptibleMask, this function has no effect.

classclass (ProfunctorFunctor f, ProfunctorFunctor u) => ProfunctorAdjunction (f :: (Type -> Type -> Type) -> Type -> Type -> Type) (u :: (Type -> Type -> Type) -> Type -> Type -> Type) | f -> u, u -> f where
#

Laws:

unit . counit ≡ id
counit . unit ≡ id

Methods

Instances6ProfunctorAdjunction
datadata GeneralCategory
#

Unicode General Categories (column 2 of the UnicodeData table) in the order they are listed in the Unicode standard (the Unicode Character Database, in particular).

Examples

Basic usage:

Example1 expression
:t OtherLetterOtherLetter :: GeneralCategory

Eq instance:

Example2 expressions
UppercaseLetter == UppercaseLetterTrueUppercaseLetter == LowercaseLetterFalse

Ord instance:

Example1 expression
NonSpacingMark <= MathSymbolTrue

Enum instance:

Example1 expression
enumFromTo ModifierLetter SpacingCombiningMark[ModifierLetter,OtherLetter,NonSpacingMark,SpacingCombiningMark]

Text.Read.Read instance:

Example2 expressions
read "DashPunctuation" :: GeneralCategoryDashPunctuationread "17" :: GeneralCategory*** Exception: Prelude.read: no parse

Show instance:

Example1 expression
show EnclosingMark"EnclosingMark"

Bounded instance:

Example2 expressions
minBound :: GeneralCategoryUppercaseLettermaxBound :: GeneralCategoryNotAssigned

Ix instance:

Example3 expressions
import GHC.Internal.Data.Ix ( index )index (OtherLetter,Control) FinalQuote12index (OtherLetter,Control) Format*** Exception: Error in array index

Constructors

Instances9Bounded, Enum, Eq, Ord, Read, Show, …
classclass Category (cat :: k -> k -> Type) where
#

A class for categories. Instances should satisfy the laws

Right identity

f . id = f

Left identity

id . f = f

Associativity

f . (g . h) = (f . g) . h

Methods

  • id :: cat a a

    the identity morphism

  • (.) :: cat b c -> cat a b -> cat a cinfixr 9

    morphism composition

Instances31Category, …
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 <$> 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.

Instances164Applicative, …
classclass Category a => Arrow (a :: Type -> Type -> Type) where
#

The basic arrow class.

Instances should satisfy the following laws:

where

assoc ((a,b),c) = (a,(b,c))

The other combinators have sensible default definitions, which may be overridden for efficiency.

Methods

  • arr :: (b -> c) -> a b c

    Lift a function to an arrow.

  • (***) :: a b c -> a b' c' -> a (b, b') (c, c')infixr 3

    Split the input between the two argument arrows and combine their output. Note that this is in general not a functor.

    The default definition may be overridden with a more efficient version if desired.

  • (&&&) :: a b c -> a b c' -> a b (c, c')infixr 3

    Fanout: send the input to both argument arrows and combine their output.

    The default definition may be overridden with a more efficient version if desired.

Instances11Arrow, …
classclass Functor w => Comonad (w :: Type -> Type) where
#

There are two ways to define a comonad:

I. Provide definitions for extract and extend satisfying these laws:

extend extract      = id
extract . extend f  = f
extend f . extend g = extend (f . extend g)

In this case, you may simply set fmap = liftW.

These laws are directly analogous to the laws for monads and perhaps can be made clearer by viewing them as laws stating that Cokleisli composition must be associative, and has extract for a unit:

f =>= extract   = f
extract =>= f   = f
(f =>= g) =>= h = f =>= (g =>= h)

II. Alternately, you may choose to provide definitions for fmap, extract, and duplicate satisfying these laws:

extract . duplicate      = id
fmap extract . duplicate = id
duplicate . duplicate    = fmap duplicate . duplicate

In this case you may not rely on the ability to define fmap in terms of liftW.

You may of course, choose to define both duplicate and extend. In that case you must also satisfy these laws:

extend f  = fmap f . duplicate
duplicate = extend id
fmap f    = extend (f . extract)

These are the default definitions of extend and duplicate and the definition of liftW respectively.

Methods

Instances26Comonad, …
datadata Chan a
#

Chan is an abstract type representing an unbounded FIFO channel.

Instances1Eq
  • Eq (Chan a)Defined in base-4.20.2.0 · Control.Concurrent.Chan
datadata MVar a
#

An MVar (pronounced "em-var") is a synchronising variable, used for communication between concurrent threads. It can be thought of as a box, which may be empty or full.

Instances3NFData1, Eq, NFData
  • NFData1 MVarDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Eq (MVar a)Defined in ghc-internal-9.1003.0 · GHC.Internal.MVar

    Compares the underlying pointers.

  • NFData (MVar a)Defined in deepseq-1.5.0.0 · Control.DeepSeq

    NOTE: Only strict in the reference and not the referenced value.

newtypenewtype QSem
#

QSem is a quantity semaphore in which the resource is acquired and released in units of one. It provides guaranteed FIFO ordering for satisfying blocked waitQSem calls.

The pattern

bracket_ waitQSem signalQSem (...)

is safe; it never loses a unit of the resource.

datadata QSemN
#

QSemN is a quantity semaphore in which the resource is acquired and released in arbitrary amounts. It provides guaranteed FIFO ordering for satisfying blocked waitQSemN calls.

The pattern

bracket_ (waitQSemN n) (signalQSemN n) (...)

is safe; it never loses any of the resource.

newtypenewtype STM a
#

A monad supporting atomic memory transactions.

Constructors

Instances20Monad, Functor, MonadFix, Applicative, Alternative, MonadPlus, …
datadata TArray i e
#

TArray is a transactional array, supporting the usual MArray interface for mutable arrays.

It is conceptually implemented as Array i (TVar e).

Instances3MArray, Eq
  • MArray TArray e STMDefined in stm-2.5.3.1 · Control.Concurrent.STM.TArray
  • MArray TArray e IODefined in stm-2.5.3.1 · Control.Concurrent.STM.TArray

    Writes are slow in IO.

  • (Eq i, Eq e) => Eq (TArray i e)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TArray
datadata TBQueue a
#

TBQueue is an abstract type representing a bounded FIFO channel.

Instances1Eq
  • Eq (TBQueue a)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TBQueue
datadata TChan a
#

TChan is an abstract type representing an unbounded FIFO channel.

Instances1Eq
  • Eq (TChan a)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TChan
newtypenewtype TMVar a
#

A TMVar is a synchronising variable, used for communication between concurrent threads. It can be thought of as a box, which may be empty or full.

Instances1Eq
  • Eq (TMVar a)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TMVar
datadata TQueue a
#

TQueue is an abstract type representing an unbounded FIFO channel.

Instances1Eq
  • Eq (TQueue a)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TQueue
datadata TVar a
#

Shared memory locations that support atomic memory transactions.

Constructors

Instances4Eq, HasGetter, HasSetter, HasUpdate
  • Eq (TVar a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • HasGetter (TVar a) aDefined in StateVar-1.2.2 · Data.StateVar
  • HasSetter (TVar a) aDefined in StateVar-1.2.2 · Data.StateVar
  • HasUpdate (TVar a) a aDefined in StateVar-1.2.2 · Data.StateVar
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

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

Instances112Monad, …
  • 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 GetDefined in binary-0.8.9.3 · Data.Binary.Get.Internal
  • Monad PutMDefined in binary-0.8.9.3 · Data.Binary.Put
  • Monad PutDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.Internal
  • Monad SeqDefined in containers-0.7 · Data.Sequence.Internal
  • Monad TreeDefined in containers-0.7 · Data.Tree
  • Monad DNonEmptyDefined in dlist-1.0 · Data.DList.DNonEmpty.Internal
  • Monad DListDefined in dlist-1.0 · Data.DList.Internal
  • Monad NonEmptyDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monad STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Monad IdentityDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Monad FirstDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monad LastDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monad DownDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Monad DualDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monad ProductDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monad SumDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monad NoIODefined in ghc-internal-9.1003.0 · GHC.Internal.GHCi
  • Monad Par1Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monad MaybeDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monad PDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadP
  • Monad ReadPDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadP
  • Monad ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrec
  • Monad SoloDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monad IODefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monad ArrayDefined in primitive-0.9.1.0 · Data.Primitive.Array
  • Monad SmallArrayDefined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • Monad STMDefined in stm-2.5.3.1 · Control.Sequential.STM
  • Monad PprMDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.PprLib
  • Monad QDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Monad VectorDefined in vector-0.13.2.0 · Data.Vector
  • Monad IdDefined in vector-0.13.2.0 · Data.Vector.Fusion.Util
  • Monad VectorDefined in vector-0.13.2.0 · Data.Vector.Strict
  • Monad BoxDefined in vector-stream-0.1.0.1 · Data.Stream.Monadic
  • Monad []Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Representable f => Monad (Co f)Defined in adjunctions-4.4.3 · Data.Functor.Rep
  • Alternative f => Monad (Cofree f)Defined in free-5.2 · Control.Comonad.Cofree
  • Applicative f => Monad (Free f)Defined in free-5.2 · Control.Monad.Free.Ap
  • Functor f => Monad (Free f)Defined in free-5.2 · Control.Monad.Free
  • Monad ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Monad U1Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monad (SetM s)Defined in containers-0.7 · Data.Graph
  • Monad (State s)Defined in containers-0.7 · Utils.Containers.Internal.State
  • Monad (F f)Defined in free-5.2 · Control.Monad.Free.Church
  • 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 (IParser t)Defined in text-2.1.3 · Data.Text.Internal.Read
  • Monad f => Monad (SelectM f)Defined in selective-0.7.0.1 · Control.Selective
  • Monad m => Monad (WrappedMonad m)Defined in base-4.20.2.0 · Control.Applicative
  • Monad m => Monad (CatchT m)Defined in exceptions-0.10.9 · Control.Monad.Catch.Pure
  • Monad m => Monad (IterT m)Defined in free-5.2 · Control.Monad.Trans.Iter
  • Monad m => Monad (Coyoneda m)Defined in kan-extensions-5.2.7 · Data.Functor.Coyoneda
  • Monad m => Monad (Yoneda m)Defined in kan-extensions-5.2.7 · Data.Functor.Yoneda
  • Monad m => Monad (MaybeT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • Monoid a => Monad (Tuple2 a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • ArrowApply a => Monad (ArrowMonad a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Arrow
  • Monad (FT f m)Defined in free-5.2 · Control.Monad.Trans.Free.Church
  • Monad (Tagged s)Defined in tagged-0.8.9 · Data.Tagged
  • Monad (bi a) => Monad (Biap bi a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biap
  • Monad (t m) => Monad (LiftingAccum t m)Defined in mtl-2.3.1 · Control.Monad.Accum
  • Monad (t m) => Monad (LiftingSelect t m)Defined in mtl-2.3.1 · Control.Monad.Select
  • Monad f => Monad (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monad f => Monad (Alt f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monad f => Monad (Rec1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monad m => Monad (Kleisli m a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Arrow
  • Monad m => Monad (StateT s m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils
  • Monad m => Monad (WrappedFunctor m)Defined in invariant-0.6.4 · Data.Functor.Invariant
  • Monad m => Monad (ExceptT e m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • Monad m => Monad (IdentityT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • Monad m => Monad (ReaderT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Reader
  • Monad m => Monad (SelectT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Select
  • Monad m => Monad (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Lazy
  • Monad m => Monad (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Strict
  • Monad m => Monad (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.CPS
  • Monad m => Monad (Reverse m)Defined in transformers-0.6.1.1 · Data.Functor.Reverse

    Derived instance.

  • (Representable f, Monad m) => Monad (ReaderT f m)Defined in adjunctions-4.4.3 · Control.Monad.Representable.Reader
  • (Representable g, Monad m) => Monad (StateT g m)Defined in adjunctions-4.4.3 · Control.Monad.Representable.State
  • (Alternative f, Monad w) => Monad (CofreeT f w)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • (Applicative f, Monad f) => Monad (WhenMissing f x)Defined in containers-0.7 · Data.IntMap.Internal

    Equivalent to ReaderT k (ReaderT x (MaybeT f)).

  • (Applicative f, Monad m) => Monad (FreeT f m)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Functor f, Monad m) => Monad (FreeT f m)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Monad (Rep p), Representable p) => Monad (Prep p)Defined in profunctors-5.6.3 · Data.Profunctor.Rep
  • (Monoid a, Monoid b) => Monad (Tuple3 a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • (Monoid w, Functor m, Monad m) => Monad (AccumT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Accum
  • (Monoid w, Monad m) => Monad (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Monoid w, Monad m) => Monad (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • (Selective f, Monad f) => Monad (ExceptT e f)Defined in selective-0.7.0.1 · Control.Selective.Trans.Except
  • Comonad w => Monad (ContsT r w m)Defined in adjunctions-4.4.3 · Control.Monad.Trans.Conts
  • Comonad w => Monad (CoT w m)Defined in kan-extensions-5.2.7 · Control.Monad.Co
  • Monad (Cokleisli w a)Defined in comonad-5.0.9 · Control.Comonad
  • Monad (Codensity f)Defined in kan-extensions-5.2.7 · Control.Monad.Codensity
  • Monad (Costar f a)Defined in profunctors-5.6.3 · Data.Profunctor.Types
  • Monad (ContT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Cont
  • Monad ((->) r)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monad f => Monad (Star f a)Defined in profunctors-5.6.3 · Data.Profunctor.Types
  • (Adjunction f g, Monad m) => Monad (AdjointT f g m)Defined in adjunctions-4.4.3 · Control.Monad.Trans.Adjoint
  • (Adjunction f g, Comonad w) => Monad (AdjointT f g w)Defined in adjunctions-4.4.3 · Control.Monad.Trans.Contravariant.Adjoint
  • (Applicative f, Monad f) => Monad (WhenMissing f k x)Defined in containers-0.7 · Data.Map.Internal

    Equivalent to ReaderT k (ReaderT x (MaybeT f)) .

  • (Monad f, Applicative f) => Monad (WhenMatched f x y)Defined in containers-0.7 · Data.IntMap.Internal

    Equivalent to ReaderT Key (ReaderT x (ReaderT y (MaybeT f)))

  • (Monad f, Monad g) => Monad (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Monad f, Monad g) => Monad (f :*: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Monoid a, Monoid b, Monoid c) => Monad (Tuple4 a b c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monad f => Monad (M1 i c f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monad m => Monad (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.CPS
  • (Monad f, Applicative f) => Monad (WhenMatched f k x y)Defined in containers-0.7 · Data.Map.Internal

    Equivalent to ReaderT k (ReaderT x (ReaderT y (MaybeT f)))

  • (Monoid w, Monad m) => Monad (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.Lazy
  • (Monoid w, Monad m) => Monad (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.Strict
typetype Cont r = ContT r Identity
#

Continuation monad. Cont r a is a CPS ("continuation-passing style") computation that produces an intermediate result of type a within a CPS computation whose final result type is r.

The return function simply creates a continuation which passes the value on.

The >>= operator adds the bound function into the continuation chain.

newtypenewtype Identity a
#

Identity functor and monad. (a non-strict monad)

Examples
Example1 expression
fmap (+1) (Identity 0)Identity 1
Example1 expression
Identity [1, 2, 3] <> Identity [4, 5, 6]Identity [1,2,3,4,5,6]
>>> do
      x <- Identity 10
      y <- Identity (x + 5)
      pure (x + y)
Identity 25

Constructors

Instances88Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
newtypenewtype ST s a
#

The strict ST monad. The ST monad allows for destructive updates, but is escapable (unlike IO). A computation of type ST s a returns a value of type a, and execute in "thread" s. The s parameter is either

  • an uninstantiated type variable (inside invocations of runST), or

  • RealWorld (inside invocations of stToIO).

It serves to keep the internal states of different invocations of runST separate from each other and from invocations of stToIO.

The >>= and >> operations are strict in the state (though not in values stored in the state). For example,

runST (writeSTRef _|_ v >>= f) = _|_
Instances36Monad, Functor, MonadFix, Applicative, MonadThrow, PrimBase, …
typetype State s = StateT s Identity
#

A state monad parameterized by the type s of the state to carry.

The return function leaves the state unchanged, while >>= uses the final state of the first computation as the initial state of the second.

typetype Except e = ExceptT e Identity
#

The parameterizable exception monad.

Computations are either exceptions or normal values.

The return function returns a normal value, while >>= exits on the first exception. For a variant that continues after an error and collects all the errors, see Errors.

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

Instances63Monad, Functor, MonadFix, MonadFail, Applicative, Foldable, …
classclass Applicative f => Selective (f :: Type -> Type) where
#

Selective applicative functors. You can think of select as a selective function application: when given a value of type Left a, you must apply the given function, but when given a Right b, you may skip the function and associated effects, and simply return the b.

Note that it is not a requirement for selective functors to skip unnecessary effects. It may be counterintuitive, but this makes them more useful. Why? Typically, when executing a selective computation, you would want to skip the effects (saving work); but on the other hand, if your goal is to statically analyse a given selective computation and extract the set of all possible effects (without actually executing them), then you do not want to skip any effects, because that defeats the purpose of static analysis.

The type signature of select is reminiscent of both <*> and >>=, and indeed a selective functor is in some sense a composition of an applicative functor and the Either monad.

Laws:

  • Identity:

x <*? pure id = either id id <$> x
  • Distributivity; note that y and z have the same type f (a -> b):

pure x <*? (y *> z) = (pure x <*? y) *> (pure x <*? z)
  • Associativity:

x <*? (y <*? z) = (f <$> x) <*? (g <$> y) <*? (h <$> z)
  where
    f x = Right <$> x
    g y = a -> bimap (,a) ($a) y
    h z = uncurry z
  • Monadic select (for selective functors that are also monads):

select = selectM

There are also a few useful theorems:

  • Apply a pure function to the result:

f <$> select x y = select (fmap f <$> x) (fmap f <$> y)
  • Apply a pure function to the Left case of the first argument:

select (first f <$> x) y = select x ((. f) <$> y)
  • Apply a pure function to the second argument:

select x (f <$> y) = select (first (flip f) <$> x) ((&) <$> y)
  • Generalised identity:

x <*? pure y = either y id <$> x
  • A selective functor is rigid if it satisfies <*> = apS. The following interchange law holds for rigid selective functors:

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

If f is also a Monad, we require that select = selectM, from which one can prove <*> = apS.

Methods

Instances37Selective, …
classclass Typeable a => Data a where
#

The Data class comprehends a fundamental primitive gfoldl for folding over constructor applications, say terms. This primitive can be instantiated in several ways to map over the immediate subterms of a term; see the gmap combinators later in this class. Indeed, a generic programmer does not necessarily need to use the ingenious gfoldl primitive but rather the intuitive gmap combinators. The gfoldl primitive is completed by means to query top-level constructors, to turn constructor representations into proper terms, and to list all possible datatype constructors. This completion allows us to serve generic programming scenarios like read, show, equality, term generation.

The combinators gmapT, gmapQ, gmapM, etc are all provided with default definitions in terms of gfoldl, leaving open the opportunity to provide datatype-specific definitions. (The inclusion of the gmap combinators as members of class Data allows the programmer or the compiler to derive specialised, and maybe more efficient code per datatype. Note: gfoldl is more higher-order than the gmap combinators. This is subject to ongoing benchmarking experiments. It might turn out that the gmap combinators will be moved out of the class Data.)

Conceptually, the definition of the gmap combinators in terms of the primitive gfoldl requires the identification of the gfoldl function arguments. Technically, we also need to identify the type constructor c for the construction of the result type from the folded term type.

In the definition of gmapQx combinators, we use phantom type constructors for the c in the type of gfoldl because the result type of a query does not involve the (polymorphic) type of the term argument. In the definition of gmapQl we simply use the plain constant type constructor because gfoldl is left-associative anyway and so it is readily suited to fold a left-associative binary operation over the immediate subterms. In the definition of gmapQr, extra effort is needed. We use a higher-order accumulation trick to mediate between left-associative constructor application vs. right-associative binary operation (e.g., (:)). When the query is meant to compute a value of type r, then the result type within generic folding is r -> r. So the result of folding is a function to which we finally pass the right unit.

With the -XDeriveDataTypeable option, GHC can generate instances of the Data class automatically. For example, given the declaration

data T a b = C1 a b | C2 deriving (Typeable, Data)

GHC will generate an instance that is equivalent to

instance (Data a, Data b) => Data (T a b) where
    gfoldl k z (C1 a b) = z C1 `k` a `k` b
    gfoldl k z C2       = z C2

    gunfold k z c = case constrIndex c of
                        1 -> k (k (z C1))
                        2 -> z C2

    toConstr (C1 _ _) = con_C1
    toConstr C2       = con_C2

    dataTypeOf _ = ty_T

con_C1 = mkConstr ty_T "C1" [] Prefix
con_C2 = mkConstr ty_T "C2" [] Prefix
ty_T   = mkDataType "Module.T" [con_C1, con_C2]

This is suitable for datatypes that are exported transparently.

Methods

  • gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> a -> c a

    Left-associative fold operation for constructor applications.

    The type of gfoldl is a headache, but operationally it is a simple generalisation of a list fold.

    The default definition for gfoldl is const id, which is suitable for abstract datatypes with no substructures.

  • gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c a

    Unfolding constructor applications

  • toConstr :: a -> Constr

    Obtaining the constructor from a given datum. For proper terms, this is meant to be the top-level constructor. Primitive datatypes are here viewed as potentially infinite sets of values (i.e., constructors).

  • dataTypeOf :: a -> DataType

    The outer type constructor of the type

  • dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c a)

    Mediate types and unary type constructors.

    In Data instances of the form

        instance (Data a, ...) => Data (T a)
    

    dataCast1 should be defined as gcast1.

    The default definition is const Nothing, which is appropriate for instances of other forms.

  • dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a)

    Mediate types and binary type constructors.

    In Data instances of the form

        instance (Data a, Data b, ...) => Data (T a b)
    

    dataCast2 should be defined as gcast2.

    The default definition is const Nothing, which is appropriate for instances of other forms.

  • gmapT :: (forall b. Data b => b -> b) -> a -> a

    A generic transformation that maps over the immediate subterms

    The default definition instantiates the type constructor c in the type of gfoldl to an identity datatype constructor, using the isomorphism pair as injection and projection.

  • gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r

    A generic query with a left-associative binary operator

  • gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r

    A generic query with a right-associative binary operator

  • gmapQ :: (forall d. Data d => d -> u) -> a -> [u]

    A generic query that processes the immediate subterms and returns a list of results. The list is given in the same order as originally specified in the declaration of the data constructors.

  • gmapQi :: Int -> (forall d. Data d => d -> u) -> a -> u

    A generic query that processes one child by index (zero-based)

  • gmapM :: Monad m => (forall d. Data d => d -> m d) -> a -> m a

    A generic monadic transformation that maps over the immediate subterms

    The default definition instantiates the type constructor c in the type of gfoldl to the monad datatype constructor, defining injection and projection using return and >>=.

  • gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> a -> m a

    Transformation of at least one immediate subterm does not fail

  • gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> a -> m a

    Transformation of one immediate subterm with success

Instances205Data, …
  • Data ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • Data ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Data ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • Data ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • Data IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Data IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data VersionDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data SpecConstrAnnotationDefined in ghc-internal-9.1003.0 · GHC.Internal.Exts
  • Data IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data AssociativityDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data DecidedStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data SourceStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data SourceUnpackednessDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data CharDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data ScientificDefined in scientific-0.3.8.0 · Data.Scientific
  • Data AnnLookupDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data AnnTargetDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data BangDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data BndrVisDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data BodyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data BytesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data CallconvDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data ClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data ConDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data DecDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data DecidedStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data DerivClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data DerivStrategyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data DocLocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data ExpDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data FamilyResultSigDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data FixityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data FixityDirectionDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data ForeignDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data FunDepDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data GuardDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data InfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data InjectivityAnnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data InlineDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data LitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data LocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data MatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data ModNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data ModuleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data ModuleInfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data NameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data NameFlavourDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data NameSpaceDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data NamespaceSpecifierDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data OccNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data OverlapDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data PatDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data PatSynArgsDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data PatSynDirDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data PhasesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data PkgNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data PragmaDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data RangeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data RoleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data RuleBndrDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data RuleMatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data SafetyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data SourceStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data SourceUnpackednessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data SpecificityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data StmtDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data TyLitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data TySynEqnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data TypeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data TypeFamilyHeadDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data TextDefined in text-2.1.3 · Data.Text · orphan

    This instance preserves data abstraction at the cost of inefficiency. We omit reflection services for the sake of data abstraction.

    This instance was created by copying the updated behavior of Data.Set.Set and Data.Map.Data.Map.Map. If you feel a mistake has been made, please feel free to submit improvements.

    The original discussion is archived here: could we get a Data instance for Data.Text.Text?

    The followup discussion that changed the behavior of Set and Data.Map.Map is archived here: Proposal: Allow gunfold for Data.Map, ...

  • Data TextDefined in text-2.1.3 · Data.Text.Lazy · orphan

    This instance preserves data abstraction at the cost of inefficiency. We omit reflection services for the sake of data abstraction.

    This instance was created by copying the updated behavior of Data.Text.Text

  • Data ConstructorInfoDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Data ConstructorVariantDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Data DatatypeInfoDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Data DatatypeVariantDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Data FieldStrictnessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Data StrictnessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Data UnpackednessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Data CalendarDiffDaysDefined in time-1.12.2 · Data.Time.Calendar.CalendarDiffDays
  • Data DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • Data MonthDefined in time-1.12.2 · Data.Time.Calendar.Month
  • Data QuarterDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Data QuarterOfYearDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Data DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Data AbsoluteTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.AbsoluteTime
  • Data DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Data NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Data SystemTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.SystemTime
  • Data UTCTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UTCTime
  • Data UniversalTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UniversalTime
  • Data CalendarDiffTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.CalendarDiffTime
  • Data LocalTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.LocalTime
  • Data TimeOfDayDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeOfDay
  • Data TimeZoneDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeZone
  • Data ZonedTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.ZonedTime
  • Data UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Data ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data a => Data (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Data a => Data (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Data a => Data (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Data a => Data (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Data a => Data (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Data a => Data (IntMap a)Defined in containers-0.7 · Data.IntMap.Internal
  • Data a => Data (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Data a => Data (ViewL a)Defined in containers-0.7 · Data.Sequence.Internal
  • Data a => Data (ViewR a)Defined in containers-0.7 · Data.Sequence.Internal
  • Data a => Data (Tree a)Defined in containers-0.7 · Data.Tree
  • Data a => Data (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data a => Data (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data a => Data (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data a => Data (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data a => Data (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data a => Data (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data a => Data (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data a => Data (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data a => Data (ConstPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data a => Data (ForeignPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data a => Data (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList
  • Data a => Data (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data a => Data (Ptr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data a => Data (Array a)Defined in primitive-0.9.1.0 · Data.Primitive.Array
  • Data a => Data (SmallArray a)Defined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • Data a => Data (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Data a => Data (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Strict
  • Data a => Data (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data a => Data [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data

    For historical reasons, the constructor name used for (:) is "(:)". In a derived instance, it would be ":".

  • Data flag => Data (TyVarBndr flag)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Data m => Data (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Data p => Data (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data vertex => Data (SCC vertex)Defined in containers-0.7 · Data.Graph
  • Typeable s => Data (MutableByteArray s)Defined in base-4.20.2.0 · Data.Array.Byte
  • (Data a, Storable a) => Data (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Storable
  • (Data a, Integral a) => Data (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Data a, Ord a) => Data (Set a)Defined in containers-0.7 · Data.Set.Internal
  • (Data a, Hashable a) => Data (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • (Data a, Prim a) => Data (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Primitive
  • (Data a, Unbox a) => Data (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Data p => Data (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data p => Data (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Data t => Data (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Data a, Data b) => Data (Arg a b)Defined in base-4.20.2.0 · Data.Semigroup
  • (Data a, Data b) => Data (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Data a, Data b) => Data (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Data a, Data b, Ix a) => Data (Array a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Data k, Data a, Ord k) => Data (Map k a)Defined in containers-0.7 · Data.Map.Internal
  • (Data k, Data v, Hashable k) => Data (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (Typeable f, Data (f (Cofree f a)), Data a) => Data (Cofree f a)Defined in free-5.2 · Control.Comonad.Cofree
  • (Typeable f, Data (f (Free f a)), Data a) => Data (Free f a)Defined in free-5.2 · Control.Monad.Free
  • (Typeable f, Data a, Data (f (Free f a))) => Data (Free f a)Defined in free-5.2 · Control.Monad.Free.Ap
  • (Typeable k, Typeable a) => Data (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • (Typeable m, Data (m (Either a (IterT m a))), Data a) => Data (IterT m a)Defined in free-5.2 · Control.Monad.Trans.Iter
  • (Typeable m, Typeable a, Data (m a)) => Data (WrappedMonad m a)Defined in base-4.20.2.0 · Control.Applicative
  • (Typeable s, Typeable a) => Data (MutableArray s a)Defined in primitive-0.9.1.0 · Data.Primitive.Array
  • (Typeable s, Typeable a) => Data (SmallMutableArray s a)Defined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • (Typeable w, Data (w (a, CoiterT w a)), Data a) => Data (CoiterT w a)Defined in free-5.2 · Control.Comonad.Trans.Coiter
  • (Data (f a), Data a, Typeable f) => Data (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Data (f a), Data a, Typeable f) => Data (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Data (f p), Typeable f, Data p) => Data (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Data a, Data b, Data c) => Data (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Data e, Typeable w, Data (w a), Data a) => Data (EnvT e w a)Defined in comonad-5.0.9 · Control.Comonad.Trans.Env
  • (Data s, Data b) => Data (Tagged s b)Defined in tagged-0.8.9 · Data.Tagged
  • (Typeable a, Typeable b, Typeable c, Data (a b c)) => Data (WrappedArrow a b c)Defined in base-4.20.2.0 · Control.Applicative
  • (Typeable b, Typeable k, Data a) => Data (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • (Typeable f, Data a, Data (f b), Data b) => Data (CofreeF f a b)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • (Typeable f, Typeable b, Data a, Data (f b)) => Data (FreeF f a b)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Typeable f, Typeable b, Data a, Data (f b)) => Data (FreeF f a b)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Typeable f, Typeable m, Data (m (FreeF f a (FreeT f m a))), Data a) => Data (FreeT f m a)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Typeable f, Typeable w, Data (w (CofreeF f a (CofreeT f w a))), Data a) => Data (CofreeT f w a)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • (Typeable k, Data a, Typeable b) => Data (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Coercible a b, Data a, Data b) => Data (Coercion a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (a ~ b, Data a) => Data (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Data a, Data b, Data c, Data d) => Data (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Typeable a, Typeable f, Typeable g, Typeable k, Data (f a), Data (g a)) => Data (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Typeable a, Typeable f, Typeable g, Typeable k, Data (f a), Data (g a)) => Data (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Typeable f, Typeable g, Data p, Data (f p), Data (g p)) => Data ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Typeable f, Typeable g, Data p, Data (f p), Data (g p)) => Data ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Typeable i, Data p, Data c) => Data (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Typeable i, Typeable j, Typeable a, Typeable b, a ~~ b) => Data (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Data a, Data b, Data c, Data d, Data e) => Data (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Data p, Data (f p), Typeable c, Typeable i, Typeable f) => Data (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Typeable a, Typeable f, Typeable g, Typeable k1, Typeable k2, Data (f (g a))) => Data (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • (Typeable f, Typeable g, Data p, Data (f (g p))) => Data ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Data a, Data b, Data c, Data d, Data e, Data f) => Data (a, b, c, d, e, f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Data a, Data b, Data c, Data d, Data e, Data f, Data g) => Data (a, b, c, d, e, f, g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
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
Instances25Bifunctor, …
classclass Functor f => Apply (f :: Type -> Type) where
#

A strong lax semi-monoidal endofunctor. This is equivalent to an Applicative without pure.

Laws:

(.) <$> u <.> v <.> w = u <.> (v <.> w)
x <.> (f <$> y) = (. f) <$> x <.> y
f <$> (x <.> y) = (f .) <$> x <.> y

The laws imply that .> and <. really ignore their left and right results, respectively, and really return their right and left results, respectively. Specifically,

(mf <$> m) .> (nf <$> n) = nf <$> (m .> n)
(mf <$> m) <. (nf <$> n) = mf <$> (m <. n)

Methods

  • (<.>) :: f (a -> b) -> f a -> f binfixl 4
  • (.>) :: f a -> f b -> f binfixl 4
     a .> b = const id <$> a <.> b
  • (<.) :: f a -> f b -> f ainfixl 4
     a <. b = const <$> a <.> b
  • liftF2 :: (a -> b -> c) -> f a -> f b -> f c

    Lift a binary function into a comonad with zipping

Instances96Apply, …
newtypenewtype Product a
#

Monoid under multiplication.

Product x <> Product y == Product (x * y)
Examples
Example1 expression
Product 3 <> Product 4 <> memptyProduct {getProduct = 12}
Example1 expression
mconcat [ Product n | n <- [2 .. 10]]Product {getProduct = 3628800}

Constructors

Instances43Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
classclass Eq a => Bits a where
#

The Bits class defines bitwise operations over integral types.

  • Bits are numbered from 0 with bit 0 being the least significant bit.

Methods

  • (.&.) :: a -> a -> ainfixl 7

    Bitwise "and"

  • (.|.) :: a -> a -> ainfixl 5

    Bitwise "or"

  • xor :: a -> a -> ainfixl 6

    Bitwise "xor"

  • complement :: a -> a

    Reverse all the bits in the argument

  • shift :: a -> Int -> ainfixl 8

    shift x i shifts x left by i bits if i is positive, or right by -i bits otherwise. Right shifts perform sign extension on signed number types; i.e. they fill the top bits with 1 if the x is negative and with 0 otherwise.

    An instance can define either this unified shift or shiftL and shiftR, depending on which is more convenient for the type in question.

  • rotate :: a -> Int -> ainfixl 8

    rotate x i rotates x left by i bits if i is positive, or right by -i bits otherwise.

    For unbounded types like Integer, rotate is equivalent to shift.

    An instance can define either this unified rotate or rotateL and rotateR, depending on which is more convenient for the type in question.

  • zeroBits :: a

    zeroBits is the value with all bits unset.

    The following laws ought to hold (for all valid bit indices n):

    This method uses clearBit (bit 0) 0 as its default implementation (which ought to be equivalent to zeroBits for types which possess a 0th bit).

  • bit :: Int -> a

    bit i is a value with the ith bit set and all other bits clear.

    Can be implemented using bitDefault if a is also an instance of Num.

    See also zeroBits.

  • setBit :: a -> Int -> a

    x `setBit` i is the same as x .|. bit i

  • clearBit :: a -> Int -> a

    x `clearBit` i is the same as x .&. complement (bit i)

  • complementBit :: a -> Int -> a

    x `complementBit` i is the same as x `xor` bit i

  • testBit :: a -> Int -> Bool

    x `testBit` i is the same as x .&. bit n /= 0

    In other words it returns True if the bit at offset @n is set.

    Can be implemented using testBitDefault if a is also an instance of Num.

  • bitSizeMaybe :: a -> Maybe Int

    Return the number of bits in the type of the argument. The actual value of the argument is ignored. Returns Nothing for types that do not have a fixed bitsize, like Integer.

  • bitSize :: a -> Int

    Return the number of bits in the type of the argument. The actual value of the argument is ignored. The function bitSize is undefined for types that do not have a fixed bitsize, like Integer.

    Default implementation based upon bitSizeMaybe provided since 4.12.0.0.

  • isSigned :: a -> Bool

    Return True if the argument is a signed type. The actual value of the argument is ignored

  • shiftL :: a -> Int -> ainfixl 8

    Shift the argument left by the specified number of bits (which must be non-negative). Some instances may throw an Overflow exception if given a negative input.

    An instance can define either this and shiftR or the unified shift, depending on which is more convenient for the type in question.

  • unsafeShiftL :: a -> Int -> a

    Shift the argument left by the specified number of bits. The result is undefined for negative shift amounts and shift amounts greater or equal to the bitSize.

    Defaults to shiftL unless defined explicitly by an instance.

  • shiftR :: a -> Int -> ainfixl 8

    Shift the first argument right by the specified number of bits. The result is undefined for negative shift amounts and shift amounts greater or equal to the bitSize. Some instances may throw an Overflow exception if given a negative input.

    Right shifts perform sign extension on signed number types; i.e. they fill the top bits with 1 if the x is negative and with 0 otherwise.

    An instance can define either this and shiftL or the unified shift, depending on which is more convenient for the type in question.

  • unsafeShiftR :: a -> Int -> a

    Shift the first argument right by the specified number of bits, which must be non-negative and smaller than the number of bits in the type.

    Right shifts perform sign extension on signed number types; i.e. they fill the top bits with 1 if the x is negative and with 0 otherwise.

    Defaults to shiftR unless defined explicitly by an instance.

  • rotateL :: a -> Int -> ainfixl 8

    Rotate the argument left by the specified number of bits (which must be non-negative).

    An instance can define either this and rotateR or the unified rotate, depending on which is more convenient for the type in question.

  • rotateR :: a -> Int -> ainfixl 8

    Rotate the argument right by the specified number of bits (which must be non-negative).

    An instance can define either this and rotateL or the unified rotate, depending on which is more convenient for the type in question.

  • popCount :: a -> Int

    Return the number of set bits in the argument. This number is known as the population count or the Hamming weight.

    Can be implemented using popCountDefault if a is also an instance of Num.

Instances66Bits, …
  • Bits IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Bits
  • Bits NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Bits
  • Bits EventTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.EPoll
  • Bits EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Poll
  • Bits CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Bits IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Bits WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Bits Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Bits Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Bits Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Bits Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Bits CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Bits Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Bits Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Bits Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Bits Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Bits BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Bits

    Interpret Bool as 1-bit bit-field

  • Bits IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Bits
  • Bits WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Bits
  • Bits a => Bits (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Bits a => Bits (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Bits a => Bits (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Bits a => Bits (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Bits a => Bits (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Bits a => Bits (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Bits a => Bits (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Bits a => Bits (Tagged s a)Defined in tagged-0.8.9 · Data.Tagged
datadata Bool
#
Instances37Bounded, Enum, Eq, Data, Ord, Read, …
  • Bounded BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Eq BoolDefined in ghc-prim-0.12.0 · GHC.Classes
  • Data BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Ord BoolDefined in ghc-prim-0.12.0 · GHC.Classes
  • Read BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Show BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Ix BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Generic BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Bits BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Bits

    Interpret Bool as 1-bit bit-field

  • FiniteBits BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Bits
  • Storable BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • SingKind BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • NFData BoolDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Pretty BoolDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Pretty BoolDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Random BoolDefined in random-1.2.1.3 · System.Random
  • Finite BoolDefined in random-1.2.1.3 · System.Random.GFinite
  • Uniform BoolDefined in random-1.2.1.3 · System.Random.Internal
  • UniformRange BoolDefined in random-1.2.1.3 · System.Random.Internal
  • Binary BoolDefined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable BoolDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Unbox BoolDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Default BoolDefined in data-default-0.8.0.1 · Data.Default.Internal
  • Lift BoolDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • SingI 'FalseDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • SingI 'TrueDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • IArray UArray BoolDefined in array-0.5.8.0 · Data.Array.Base
  • Vector Vector BoolDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector BoolDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MArray IOUArray Bool IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • MArray (STUArray s) Bool (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • type Rep Bool = D1 ('MetaData "Bool" "GHC.Types" "ghc-prim" 'False) (C1 ('MetaCons "False" 'PrefixI 'False) U1 :+: C1 ('MetaCons "True" 'PrefixI 'False) U1)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • type DemoteRep Bool = BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • data Sing
    • STrue :: R:SingBoola 'True
    • SFalse :: R:SingBoola 'False
    Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • data MVector s BoolDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector BoolDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
datadata ByteString
#

A space-efficient representation of a Word8 vector, supporting many efficient operations.

A ByteString contains 8-bit bytes, or by using the operations from Data.ByteString.Char8 it can be interpreted as containing 8-bit characters.

Instances14IsList, Eq, Data, Ord, Read, Show, …
  • IsList ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Eq ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Data ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Ord ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Read ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Show ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • IsString ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type

    Beware: fromString truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�

  • Semigroup ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Monoid ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • NFData ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Binary ByteStringDefined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable ByteStringDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Lift ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • type Item ByteString = Word8Defined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
datadata Scientific
#

An arbitrary-precision number represented using scientific notation.

This type describes the set of all Reals which have a finite decimal expansion.

A scientific number with coefficient c and base10Exponent e corresponds to the Fractional number: fromInteger c * 10 ^^ e

Instances13Eq, Fractional, Data, Num, Ord, Read, …
  • Eq ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    Scientific numbers can be safely compared for equality. No magnitude 10^e is calculated so there's no risk of a blowup in space or time when comparing scientific numbers coming from untrusted sources.

  • Fractional ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    WARNING: recip and / will throw an error when their outputs are repeating decimals.

    These methods also compute Integer magnitudes (10^e). If these methods are applied to arguments which have huge exponents this could fill up all space and crash your program! So don't apply these methods to scientific numbers coming from untrusted sources.

    fromRational will throw an error when the input Rational is a repeating decimal. Consider using fromRationalRepetend for these rationals which will detect the repetition and indicate where it starts.

  • Data ScientificDefined in scientific-0.3.8.0 · Data.Scientific
  • Num ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    WARNING: + and - compute the Integer magnitude: 10^e where e is the difference between the base10Exponents of the arguments. If these methods are applied to arguments which have huge exponents this could fill up all space and crash your program! So don't apply these methods to scientific numbers coming from untrusted sources. The other methods can be used safely.

  • Ord ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    Scientific numbers can be safely compared for ordering. No magnitude 10^e is calculated so there's no risk of a blowup in space or time when comparing scientific numbers coming from untrusted sources.

  • Read ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    Supports the skipping of parentheses and whitespaces. Example:

    > read " ( ((  -1.0e+3 ) ))" :: Scientific
    -1000.0

    (Note: This Read instance makes internal use of scientificP to parse the floating-point number.)

  • Real ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    WARNING: toRational needs to compute the Integer magnitude: 10^e. If applied to a huge exponent this could fill up all space and crash your program!

    Avoid applying toRational (or realToFrac) to scientific numbers coming from an untrusted source and use toRealFloat instead. The latter guards against excessive space usage.

  • RealFrac ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    WARNING: the methods of the RealFrac instance need to compute the magnitude 10^e. If applied to a huge exponent this could take a long time. Even worse, when the destination type is unbounded (i.e. Integer) it could fill up all space and crash your program!

  • Show ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    See formatScientific if you need more control over the rendering.

  • NFData ScientificDefined in scientific-0.3.8.0 · Data.Scientific
  • Binary ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    Note that in the future I intend to change the type of the base10Exponent from Int to Integer. To be forward compatible the Binary instance already encodes the exponent as Integer.

  • Hashable ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    A hash can be safely calculated from a Scientific. No magnitude 10^e is calculated so there's no risk of a blowup in space or time when hashing scientific numbers coming from untrusted sources.

    Example4 expressions
    import Data.Hashable (hash)let x = scientific 1 2let y = scientific 100 0(x == y, hash x == hash y)(True,True)
  • Lift ScientificDefined in scientific-0.3.8.0 · Data.Scientific
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.

Instances44Bounded, Enum, Data, Read, Ix, Storable, …
datadata Complex a
#

A data type representing complex numbers.

You can read about complex numbers on wikipedia.

In haskell, complex numbers are represented as a :+ b which can be thought of as representing a + bi. For a complex number z, abs z is a number with the magnitude of z, but oriented in the positive real direction, whereas signum z has the phase of z, but unit magnitude. Apart from the loss of precision due to IEEE754 floating point numbers, it holds that z == abs z * signum z.

Note that Complex's instances inherit the deficiencies from the type parameter's. For example, Complex Float's Ord instance has similar problems to Float's.

As can be seen in the examples, the Foldable and Traversable instances traverse the real part first.

Examples
Example1 expression
(5.0 :+ 2.5) + 6.511.5 :+ 2.5
Example1 expression
abs (1.0 :+ 1.0) - sqrt 2.00.0 :+ 0.0
Example1 expression
abs (signum (4.0 :+ 3.0))1.0 :+ 0.0
Example1 expression
foldr (:) [] (1 :+ 2)[1,2]
Example1 expression
mapM print (1 :+ 2)12

Constructors

  • a :+ ainfix 6

    forms a complex number from its real and imaginary rectangular components.

Instances41Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
newtypenewtype DList a
#

A difference list is an abstraction representing a list that supports \mathcal{O}(1) append and snoc operations, making it useful for replacing frequent applications of ++ such as logging and pretty printing (esp. if those uses of ++ are left-nested).

Instances18Monad, Functor, MonadFail, Applicative, Foldable, Traversable, …
datadata Dynamic where
#

A value of type Dynamic is an object encapsulated together with its type.

A Dynamic may only represent a monomorphic value; an attempt to create a value of type Dynamic from a polymorphically-typed expression will result in an ambiguity error (see toDyn).

Showing a value of type Dynamic returns a pretty-printed representation of the object's type; useful for debugging.

Constructors

Instances2Show, Exception
  • Show DynamicDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Dynamic
  • Exception DynamicDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Dynamic
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

Instances67Bifoldable, Bifoldable1, Bifunctor, Bitraversable, Eq2, Ord2, …
datadata Validation e a
#

Selective instance for the standard applicative functor Validation. This is a good example of a non-trivial selective functor which is not a monad.

Constructors

Instances6Functor, Applicative, Selective, Eq, Ord, Show
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

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

    Equality of constructors

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

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

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

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

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

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

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

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

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

    Byte equality of the internal representation.

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

    Byte equality of the internal representation.

  • Eq PosixCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Eq PosixStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Eq WindowsCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Eq WindowsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Eq ModeDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Eq StyleDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Eq TextDetailsDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Eq PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Eq DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJ
  • Eq PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Eq CardinalityDefined in random-1.2.1.3 · System.Random.GFinite
  • Eq StdGenDefined in random-1.2.1.3 · System.Random.Internal
  • Eq ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    Scientific numbers can be safely compared for equality. No magnitude 10^e is calculated so there's no risk of a blowup in space or time when comparing scientific numbers coming from untrusted sources.

  • Eq TSemDefined in stm-2.5.3.1 · Control.Concurrent.STM.TSem
  • Eq AnnLookupDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq AnnTargetDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq BangDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq BndrVisDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq BodyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq BytesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq CallconvDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq ClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq ConDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq DecDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq DecidedStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq DerivClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq DerivStrategyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq DocLocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq ExpDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq FamilyResultSigDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq FixityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq FixityDirectionDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq ForeignDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq FunDepDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq GuardDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq InfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq InjectivityAnnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq InlineDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq LitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq LocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq MatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq ModNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq ModuleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq ModuleInfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq NameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq NameFlavourDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq NameSpaceDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq NamespaceSpecifierDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq OccNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq OverlapDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq PatDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq PatSynArgsDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq PatSynDirDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq PhasesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq PkgNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq PragmaDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq RangeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq RoleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq RuleBndrDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq RuleMatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq SafetyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq SourceStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq SourceUnpackednessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq SpecificityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq StmtDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq TyLitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq TySynEqnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq TypeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq TypeFamilyHeadDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq UnicodeExceptionDefined in text-2.1.3 · Data.Text.Encoding.Error
  • Eq I8Defined in text-2.1.3 · Data.Text.Foreign
  • Eq TextDefined in text-2.1.3 · Data.Text · orphan
  • Eq BuilderDefined in text-2.1.3 · Data.Text.Internal.Builder
  • Eq PartialUtf8CodePointDefined in text-2.1.3 · Data.Text.Internal.Encoding
  • Eq Utf8StateDefined in text-2.1.3 · Data.Text.Internal.Encoding
  • Eq DecoderStateDefined in text-2.1.3 · Data.Text.Internal.Encoding.Utf8
  • Eq SizeDefined in text-2.1.3 · Data.Text.Internal.Fusion.Size
  • Eq TextDefined in text-2.1.3 · Data.Text.Lazy · orphan
  • Eq ConstructorInfoDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Eq ConstructorVariantDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Eq DatatypeInfoDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Eq DatatypeVariantDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Eq FieldStrictnessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Eq StrictnessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Eq UnpackednessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Eq CalendarDiffDaysDefined in time-1.12.2 · Data.Time.Calendar.CalendarDiffDays
  • Eq DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • Eq MonthDefined in time-1.12.2 · Data.Time.Calendar.Month
  • Eq QuarterDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Eq QuarterOfYearDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Eq DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Eq FirstWeekTypeDefined in time-1.12.2 · Data.Time.Calendar.WeekDate
  • Eq AbsoluteTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.AbsoluteTime
  • Eq DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Eq NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Eq SystemTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.SystemTime
  • Eq UTCTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UTCTime
  • Eq UniversalTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UniversalTime
  • Eq TimeLocaleDefined in time-1.12.2 · Data.Time.Format.Locale
  • Eq CalendarDiffTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.CalendarDiffTime
  • Eq LocalTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.LocalTime
  • Eq TimeOfDayDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeOfDay
  • Eq TimeZoneDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeZone
  • Eq SubHashPathDefined in unordered-containers-0.2.21 · Data.HashMap.Internal.Debug
  • Eq UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Eq UnpackedUUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Eq SizeDefined in vector-0.13.2.0 · Data.Vector.Fusion.Bundle.Size
  • Eq ChecksDefined in vector-0.13.2.0 · Data.Vector.Internal.Check
  • Eq ()Defined in ghc-prim-0.12.0 · GHC.Classes
  • Eq (Chan a)Defined in base-4.20.2.0 · Control.Concurrent.Chan
  • Eq (MutableByteArray s)Defined in base-4.20.2.0 · Data.Array.Byte
  • Eq (TVar a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Eq (ConstPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.ConstPtr
  • Eq (ForeignPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ForeignPtr
  • Eq (IOPort a)Defined in ghc-internal-9.1003.0 · GHC.Internal.IOPort
  • Eq (IORef a)Defined in ghc-internal-9.1003.0 · GHC.Internal.IORef

    Pointer equality.

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

    Compares the underlying pointers.

  • Eq (FunPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Eq (Ptr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Eq (StablePtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Stable
  • Eq (StableName a)Defined in ghc-internal-9.1003.0 · GHC.Internal.StableName
  • Eq (SChar c)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Eq (SSymbol s)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Eq (SNat n)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • Eq (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Eq (TBQueue a)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TBQueue
  • Eq (TChan a)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TChan
  • Eq (TMVar a)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TMVar
  • Eq (TQueue a)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TQueue
  • Eq (TVar a)Defined in stm-2.5.3.1 · Control.Sequential.STM
  • Eq a => Eq (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Eq a => Eq (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Eq a => Eq (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Eq a => Eq (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Eq a => Eq (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Eq a => Eq (IntMap a)Defined in containers-0.7 · Data.IntMap.Internal
  • Eq a => Eq (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Eq a => Eq (ViewL a)Defined in containers-0.7 · Data.Sequence.Internal
  • Eq a => Eq (ViewR a)Defined in containers-0.7 · Data.Sequence.Internal
  • Eq a => Eq (Intersection a)Defined in containers-0.7 · Data.Set.Internal
  • Eq a => Eq (Set a)Defined in containers-0.7 · Data.Set.Internal
  • Eq a => Eq (Tree a)Defined in containers-0.7 · Data.Tree
  • Eq a => Eq (DNonEmpty a)Defined in dlist-1.0 · Data.DList.DNonEmpty.Internal
  • Eq a => Eq (DList a)Defined in dlist-1.0 · Data.DList.Internal
  • 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 (Hashed a)Defined in hashable-1.4.7.0 · Data.Hashable.Class

    Uses precomputed hash to detect inequality faster

  • Eq a => Eq (AnnotDetails a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Eq a => Eq (Span a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Eq a => Eq (Array a)Defined in primitive-0.9.1.0 · Data.Primitive.Array
  • Eq a => Eq (SmallArray a)Defined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • Eq a => Eq (Stream a)Defined in text-2.1.3 · Data.Text.Internal.Fusion.Types
  • Eq a => Eq (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal

    Note that, in the presence of hash collisions, equal HashSets may behave differently, i.e. extensionality may be violated:

    Example2 expressions
    data D = A | B deriving (Eq, Show)instance Hashable D where hashWithSalt salt _d = salt
    Example2 expressions
    x = fromList [A, B]y = fromList [B, A]
    Example3 expressions
    x == yTruetoList x[A,B]toList y[B,A]

    In general, the lack of extensionality can be observed with any function that depends on the key ordering, such as folds and traversals.

  • Eq a => Eq (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Eq a => Eq (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Strict
  • Eq a => Eq (a)Defined in ghc-prim-0.12.0 · GHC.Classes
  • Eq a => Eq [a]Defined in ghc-prim-0.12.0 · GHC.Classes
  • Eq flag => Eq (TyVarBndr flag)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Eq g => Eq (StateGen g)Defined in random-1.2.1.3 · System.Random.Internal
  • Eq g => Eq (AtomicGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Eq g => Eq (IOGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Eq g => Eq (STGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Eq g => Eq (TGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Eq k => Eq (Error k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal.Debug
  • Eq k => Eq (Validity k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal.Debug
  • Eq m => Eq (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Eq p => Eq (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq vertex => Eq (SCC vertex)Defined in containers-0.7 · Data.Graph
  • (Storable a, Eq a) => Eq (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Storable
  • (Eq a, Prim a) => Eq (PrimArray a)Defined in primitive-0.9.1.0 · Data.Primitive.PrimArray
  • (Prim a, Eq a) => Eq (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Primitive
  • (Unbox a, Eq a) => Eq (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Unboxed · orphan
  • Eq (IOUArray i e)Defined in array-0.5.8.0 · Data.Array.IO.Internals
  • Eq (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Eq (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Eq (TypeRep a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Typeable.Internal
  • Eq (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (IOArray i e)Defined in ghc-internal-9.1003.0 · GHC.Internal.IOArray
  • Eq (STRef s a)Defined in ghc-internal-9.1003.0 · GHC.Internal.STRef

    Pointer equality.

  • Eq (MutableArray s a)Defined in primitive-0.9.1.0 · Data.Primitive.Array
  • Eq (MVar s a)Defined in primitive-0.9.1.0 · Data.Primitive.MVar
  • Eq (MutVar s a)Defined in primitive-0.9.1.0 · Data.Primitive.MutVar
  • Eq (MutablePrimArray s a)Defined in primitive-0.9.1.0 · Data.Primitive.PrimArray
  • Eq (PrimVar s a)Defined in primitive-0.9.1.0 · Data.Primitive.PrimVar
  • Eq (SmallMutableArray s a)Defined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • Eq a => Eq (Arg a b)Defined in base-4.20.2.0 · Data.Semigroup
  • Eq m => Eq (Over m a)Defined in selective-0.7.0.1 · Control.Selective
  • Eq m => Eq (Under m a)Defined in selective-0.7.0.1 · Control.Selective
  • Eq m => Eq (Over m a)Defined in selective-0.7.0.1 · Control.Selective.Multi
  • Eq m => Eq (Under m a)Defined in selective-0.7.0.1 · Control.Selective.Multi
  • (Eq1 f, Eq a) => Eq (Ap f a)Defined in free-5.2 · Control.Applicative.Free
  • (Eq1 f, Eq a) => Eq (Cofree f a)Defined in free-5.2 · Control.Comonad.Cofree
  • (Eq1 f, Eq a) => Eq (Free f a)Defined in free-5.2 · Control.Monad.Free
  • (Eq1 f, Eq a) => Eq (Free f a)Defined in free-5.2 · Control.Monad.Free.Ap
  • (Eq1 f, Eq a) => Eq (Coyoneda f a)Defined in kan-extensions-5.2.7 · Data.Functor.Coyoneda
  • (Eq1 f, Eq a) => Eq (Yoneda f a)Defined in kan-extensions-5.2.7 · Data.Functor.Yoneda
  • (Eq1 f, Eq a) => Eq (Lift f a)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • (Eq1 m, Eq a) => Eq (IterT m a)Defined in free-5.2 · Control.Monad.Trans.Iter
  • (Eq1 m, Eq a) => Eq (MaybeT m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • (Eq1 w, Eq a) => Eq (CoiterT w a)Defined in free-5.2 · Control.Comonad.Trans.Coiter
  • (Ix i, Eq e) => Eq (Array i e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Arr
  • (Ix ix, Eq e, IArray UArray e) => Eq (UArray ix e)Defined in array-0.5.8.0 · Data.Array.Base
  • (Eq a, Eq b) => Eq (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either
  • (Eq a, Eq b) => Eq (a, b)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Eq e, Eq a) => Eq (Validation e a)Defined in either-5.0.3 · Data.Either.Validation
  • (Eq e, Eq a) => Eq (Validation e a)Defined in selective-0.7.0.1 · Control.Selective
  • (Eq i, Eq e) => Eq (TArray i e)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TArray
  • (Eq k, Eq a) => Eq (Map k a)Defined in containers-0.7 · Data.Map.Internal
  • (Eq k, Eq v) => Eq (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal

    Note that, in the presence of hash collisions, equal HashMaps may behave differently, i.e. extensionality may be violated:

    Example2 expressions
    data D = A | B deriving (Eq, Show)instance Hashable D where hashWithSalt salt _d = salt
    Example2 expressions
    x = fromList [(A,1), (B,2)]y = fromList [(B,2), (A,1)]
    Example3 expressions
    x == yTruetoList x[(A,1),(B,2)]toList y[(B,2),(A,1)]

    In general, the lack of extensionality can be observed with any function that depends on the key ordering, such as folds and traversals.

  • (Eq k, Eq v) => Eq (Leaf k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (GEq (Rep1 f a), Generic1 f) => Eq (FunctorClassesDefault f a)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Eq (STUArray s i e)Defined in array-0.5.8.0 · Data.Array.Base
  • Eq (STArray s i e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Arr
  • Eq (Coercion a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • Eq (OrderingI a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Ord
  • Eq (URec Char p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec Int p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec Word p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec (Ptr ()) p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Eq (bi a b) => Eq (Biap bi a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biap
  • 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 a) => Eq (WrappedContravariant f a)Defined in invariant-0.6.4 · Data.Functor.Invariant
  • Eq (f a) => Eq (WrappedFunctor f a)Defined in invariant-0.6.4 · Data.Functor.Invariant
  • Eq (f p) => Eq (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (p (Fix p a) a) => Eq (Fix p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Fix
  • Eq (p a a) => Eq (Join p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Join
  • Eq (w (CofreeF f a (CofreeT f w a))) => Eq (CofreeT f w a)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • Eq a => Eq (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Eq a => Eq (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • Eq a => Eq (Bundle Id v a)Defined in vector-0.13.2.0 · Data.Vector.Fusion.Bundle · orphan
  • Eq b => Eq (Tagged s b)Defined in tagged-0.8.9 · Data.Tagged
  • (Eq1 f, Eq1 m, Eq a) => Eq (FreeT f m a)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Eq1 f, Eq1 m, Eq a) => Eq (FreeT f m a)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Eq1 f, Eq a) => Eq (Backwards f a)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • (Eq1 f, Eq a) => Eq (IdentityT f a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • (Eq1 f, Eq a) => Eq (Reverse f a)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • (Eq1 f, Eq e, Eq a) => Eq (ExceptT e f a)Defined in selective-0.7.0.1 · Control.Selective.Trans.Except
  • (Functor f, Monad m, Eq1 f, Eq1 m, Eq a) => Eq (FT f m a)Defined in free-5.2 · Control.Monad.Trans.Free.Church
  • (Generic1 f, Eq (Rep1 f a)) => Eq (Generically1 f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Eq a, Eq (f b)) => Eq (CofreeF f a b)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • (Eq a, Eq (f b)) => Eq (FreeF f a b)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Eq a, Eq (f b)) => Eq (FreeF f a b)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Eq a, Eq b, Eq c) => Eq (a, b, c)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Eq e, Eq1 m, Eq a) => Eq (ExceptT e m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • (Eq w, Eq1 m, Eq a) => Eq (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Eq w, Eq1 m, Eq a) => Eq (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • Eq (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Eq c => Eq (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Eq (f a), Eq (g a)) => Eq (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Eq (f a), Eq (g a)) => Eq (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Eq (f p), Eq (g p)) => Eq ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Eq (f p), Eq (g p)) => Eq ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Eq a, Eq b, Eq c, Eq d) => Eq (a, b, c, d)Defined in ghc-prim-0.12.0 · GHC.Classes
  • Eq (f (g a)) => Eq (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Eq (f (g p)) => Eq ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (f a) => Eq (Clown f a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Clown
  • Eq (f p) => Eq (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (g b) => Eq (Joker g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Joker
  • Eq (p a b) => Eq (WrappedBifunctor p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Wrapped
  • Eq (p a b) => Eq (WrappedProfunctor p a b)Defined in invariant-0.6.4 · Data.Functor.Invariant
  • Eq (p b a) => Eq (Flip p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Flip
  • (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 (f a b), Eq (g a b)) => Eq (Product f g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Product
  • (Eq (p a b), Eq (q a b)) => Eq (Sum p q a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Sum
  • (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 (f (p a b)) => Eq (Tannen f p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Tannen
  • (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 (p (f a) (g b)) => Eq (Biff p f g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biff
  • (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
newtypenewtype Fixed (a :: k)
#

The type of fixed-point fractional numbers. The type parameter specifies the number of digits of the fractional part and should be an instance of the HasResolution typeclass.

Examples
 MkFixed 12345 :: Fixed E3

Constructors

Instances16Lift, NFData1, Enum, Eq, Fractional, Data, …
  • Lift (Fixed a)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • NFData1 FixedDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • 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.

  • Eq (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • HasResolution a => Fractional (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • (Typeable k, Typeable a) => Data (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • HasResolution a => Num (Fixed a)Defined in base-4.20.2.0 · Data.Fixed

    Multiplication is not associative or distributive:

    Example1 expression
    (0.2 * 0.6 :: Deci) * 0.9 == 0.2 * (0.6 * 0.9)False
    Example1 expression
    (0.1 + 0.1 :: Deci) * 0.5 == 0.1 * 0.5 + 0.1 * 0.5False
  • Ord (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • HasResolution a => Read (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • HasResolution a => Real (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • HasResolution a => RealFrac (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • HasResolution a => Show (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • NFData (Fixed a)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • Binary (Fixed a)Defined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable (Fixed a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • HasResolution a => Default (Fixed a)Defined in data-default-0.8.0.1 · Data.Default.Internal
classclass Foldable (t :: Type -> Type) where
#

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

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

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

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

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

Methods

  • fold :: Monoid m => t m -> m

    Given a structure with elements whose type is a Monoid, combine them via the monoid's (<>) operator. This fold is right-associative and lazy in the accumulator. When you need a strict left-associative fold, use foldMap' instead, with id as the map.

    Examples

    Basic usage:

    Example1 expression
    fold [[1, 2, 3], [4, 5], [6], []][1,2,3,4,5,6]
    Example1 expression
    fold $ Node (Leaf (Sum 1)) (Sum 3) (Leaf (Sum 5))Sum {getSum = 9}

    Folds of unbounded structures do not terminate when the monoid's (<>) operator is strict:

    Example1 expression
    fold (repeat Nothing)* Hangs forever *

    Lazy corecursive folds of unbounded structures are fine:

    Example2 expressions
    take 12 $ fold $ map (\i -> [i..i+2]) [0..][0,1,2,1,2,3,2,3,4,3,4,5]sum $ take 4000000 $ fold $ map (\i -> [i..i+2]) [0..]2666668666666
  • foldMap :: Monoid m => (a -> m) -> t a -> m

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

    Examples

    Basic usage:

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

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

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

    A left-associative variant of foldMap that is strict in the accumulator. Use this method for strict reduction when partial results are merged via (<>).

    Examples

    Define a Monoid over finite bit strings under xor. Use it to strictly compute the xor of a list of Int values.

    Example11 expressions
    :set -XGeneralizedNewtypeDerivingimport Data.Bits (Bits, FiniteBits, xor, zeroBits)import Data.Foldable (foldMap')import Numeric (showHex)newtype X a = X a deriving (Eq, Bounded, Enum, Bits, FiniteBits)instance Bits a => Semigroup (X a) where X a <> X b = X (a `xor` b)instance Bits a => Monoid    (X a) where mempty     = X zeroBitslet bits :: [Int]; bits = [0xcafe, 0xfeed, 0xdeaf, 0xbeef, 0x5411](\ (X a) -> showString "0x" . showHex a $ "") $ foldMap' X bits"0x42"
  • foldr :: (a -> b -> b) -> b -> t a -> b

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

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

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

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

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

    foldr f z = foldr f z . toList
    Examples

    Basic usage:

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

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

    It may still terminate under one of the following conditions:

    • the folding function is short-circuiting

    • the folding function is lazy on its second argument

    Short-circuiting

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

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

    But the following doesn't terminate:

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

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

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

    foldr' is a variant of foldr that performs strict reduction from right to left, i.e. starting with the right-most element. The input structure must be finite, otherwise foldr' runs out of space (diverges).

    If you want a strict right fold in constant space, you need a structure that supports faster than O(n) access to the right-most element, such as Seq from the containers package.

    This method does not run in constant space for structures such as lists that don't support efficient right-to-left iteration and so require O(n) space to perform right-to-left reduction. Use of this method with such a structure is a hint that the chosen structure may be a poor fit for the task at hand. If the order in which the elements are combined is not important, use foldl' instead.

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

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

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

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

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

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

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

    foldl f z = foldl f z . toList
    Examples

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Examples

    Basic usage:

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

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

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

    foldl1 f = foldl1 f . toList
    Examples

    Basic usage:

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

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

    Examples

    Basic usage:

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

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

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

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

    Examples

    Basic usage:

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

    Does the element occur in the structure?

    Note: elem is often used in infix form.

    Examples

    Basic usage:

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

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

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

    The largest element of a non-empty structure.

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

    Examples

    Basic usage:

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

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

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

    The least element of a non-empty structure.

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

    Examples

    Basic usage:

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

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

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

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

    Examples

    Basic usage:

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

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

    Examples

    Basic usage:

    Example1 expression
    product []1
    Example1 expression
    product [42]42
    Example1 expression
    product [1..10]3628800
    Example1 expression
    product [4.1, 2.0, 1.7]13.939999999999998
    Example1 expression
    product [1..]* Hangs forever *
Instances112Foldable, …
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
Instances241Functor, …
classclass Functor f => Alt (f :: Type -> Type) where
#

Laws:

<!> is associative:             (a <!> b) <!> c = a <!> (b <!> c)
<$> left-distributes over <!>:  f <$> (a <!> b) = (f <$> a) <!> (f <$> b)

If extended to an Alternative then <!> should equal <|>.

Ideally, an instance of Alt also satisfies the "left distribution" law of MonadPlus with respect to <.>:

<.> right-distributes over <!>: (a <!> b) <.> c = (a <.> c) <!> (b <.> c)

IO, Either a, ExceptT e m and GHC.Conc.STM instead satisfy the "left catch" law:

pure a <!> b = pure a

Maybe and Identity satisfy both "left distribution" and "left catch".

These variations cannot be stated purely in terms of the dependencies of Alt.

When and if MonadPlus is successfully refactored, this class should also be refactored to remove these instances.

The right distributive law should extend in the cases where the a Bind or Monad is provided to yield variations of the right distributive law:

(m <!> n) >>- f = (m >>- f) <!> (m >>- f)
(m <!> n) >>= f = (m >>= f) <!> (m >>= f)

Methods

  • (<!>) :: f a -> f a -> f ainfixl 3

    <|> without a required empty

Instances50Alt, …
  • Alt FirstDefined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt LastDefined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt IntMapDefined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt SeqDefined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt NonEmptyDefined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt IdentityDefined in semigroupoids-6.0.1 · Data.Functor.Alt

    Choose the first option every time. While 'choose the last option' every time is also valid, this instance satisfies more laws.

  • Alt FirstDefined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt LastDefined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt MaybeDefined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt IODefined in semigroupoids-6.0.1 · Data.Functor.Alt

    This instance does not actually satisfy the (<.>) right distributive law It instead satisfies the "left catch" law

  • Alt VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Alt []Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alternative f => Alt (WrappedApplicative f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • MonadPlus m => Alt (WrappedMonad m)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Semigroup e => Alt (Validation e)Defined in either-5.0.3 · Data.Either.Validation

    For two errors, this instance reports both of them.

  • Ord k => Alt (Map k)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt ProxyDefined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt U1Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt V1Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt (Alt f)Defined in free-5.2 · Control.Alternative.Free
  • Alt (Alt f)Defined in free-5.2 · Control.Alternative.Free.Final
  • Alt (Either a)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt f => Alt (Coyoneda f)Defined in kan-extensions-5.2.7 · Data.Functor.Coyoneda
  • Alt f => Alt (Yoneda f)Defined in kan-extensions-5.2.7 · Data.Functor.Yoneda
  • Alt f => Alt (Lift f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • (Functor f, Monad f) => Alt (MaybeT f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • (Hashable k, Eq k) => Alt (HashMap k)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • ArrowPlus a => Alt (WrappedArrow a b)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt f => Alt (Rec1 f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt f => Alt (Static f a)Defined in semigroupoids-6.0.1 · Data.Semigroupoid.Static
  • Alt f => Alt (Backwards f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt f => Alt (IdentityT f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt f => Alt (ReaderT e f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt f => Alt (StateT e f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt f => Alt (StateT e f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt f => Alt (WriterT w f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt f => Alt (WriterT w f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt f => Alt (WriterT w f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt f => Alt (Reverse f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • (Functor f, Monad f, Semigroup e) => Alt (ExceptT e f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Semigroup c => Alt (K1 i c)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
    since 5.3.8
  • (Alt f, Alt g) => Alt (Product f g)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • (Alt f, Alt g) => Alt (f :*: g)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • (v ~~ v', Alt v') => Alt (Codensity v)Defined in kan-extensions-5.2.7 · Control.Monad.Codensity
  • Alt f => Alt (M1 i c f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt f => Alt (RWST r w s f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt f => Alt (RWST r w s f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Alt f => Alt (RWST r w s f)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • (Alt f, Functor g) => Alt (Compose f g)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • (Alt f, Functor g) => Alt (f :.: g)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
classclass Apply m => Bind (m :: Type -> Type) where
#

A Monad sans return.

Minimal definition: Either join or >>-

If defining both, then the following laws (the default definitions) must hold:

join = (>>- id)
m >>- f = join (fmap f m)

Laws:

induced definition of <.>: f <.> x = f >>- (<$> x)

Finally, there are two associativity conditions:

associativity of (>>-):    (m >>- f) >>- g == m >>- (\x -> f x >>- g)
associativity of join:     join . join = join . fmap join

These can both be seen as special cases of the constraint that

associativity of (->-): (f ->- g) ->- h = f ->- (g ->- h)

Methods

  • (>>-) :: m a -> (a -> m b) -> m binfixl 1
Instances63Bind, …
  • Bind ComplexDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind FirstDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind LastDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind MaxDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind MinDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind IntMapDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class

    An IntMap is not a Monad, but it is an instance of Bind

  • Bind SeqDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind TreeDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind NonEmptyDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind IdentityDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind FirstDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind LastDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind DownDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind DualDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind ProductDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind SumDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind Par1Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind MaybeDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind IODefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind QDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Bind []Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Representable f => Bind (Co f)Defined in adjunctions-4.4.3 · Data.Functor.Rep
  • Functor f => Bind (Free f)Defined in free-5.2 · Control.Monad.Free
  • Monad m => Bind (WrappedMonad m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Monad m => Bind (IterT m)Defined in free-5.2 · Control.Monad.Trans.Iter
  • Semigroup m => Bind (Tuple2 m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class

    A (,) m is not a Monad unless its m is a Monoid, but it is an instance of Bind

  • Ord k => Bind (Map k)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class

    A 'Map k' is not a Monad, but it is an instance of Bind

  • Apply f => Bind (Free f)Defined in free-5.2 · Control.Monad.Free.Ap
  • Bind ProxyDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind U1Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind V1Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class

    A V1 is not a Monad, but it is an instance of Bind

  • Bind (F f)Defined in free-5.2 · Control.Monad.Free.Church
  • Bind (Either a)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind m => Bind (Coyoneda m)Defined in kan-extensions-5.2.7 · Data.Functor.Coyoneda
  • Bind m => Bind (Yoneda m)Defined in kan-extensions-5.2.7 · Data.Functor.Yoneda
  • (Functor m, Monad m) => Bind (MaybeT m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • (Hashable k, Eq k) => Bind (HashMap k)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class

    A 'HashMap k' is not a Monad, but it is an instance of Bind

  • Bind (FT f m)Defined in free-5.2 · Control.Monad.Trans.Free.Church
  • Bind (Tagged a)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind f => Bind (Alt f)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind m => Bind (Rec1 m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind m => Bind (IdentityT m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind m => Bind (ReaderT e m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind m => Bind (StateT s m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind m => Bind (StateT s m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind m => Bind (WriterT w m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • (Representable f, Bind m) => Bind (ReaderT f m)Defined in adjunctions-4.4.3 · Control.Monad.Representable.Reader
  • (Representable g, Bind m) => Bind (StateT g m)Defined in adjunctions-4.4.3 · Control.Monad.Representable.State
  • (Functor f, Monad m) => Bind (FreeT f m)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Functor m, Monad m) => Bind (ExceptT e m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • (Apply f, Apply m, Monad m) => Bind (FreeT f m)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Bind m, Semigroup w) => Bind (WriterT w m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class

    A WriterT w m is not a Monad unless its w is a Monoid, but it is an instance of Bind

  • (Bind m, Semigroup w) => Bind (WriterT w m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class

    A WriterT w m is not a Monad unless its w is a Monoid, but it is an instance of Bind

  • Bind (ContT r m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind ((->) m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Extend w => Bind (CoT w m)Defined in kan-extensions-5.2.7 · Control.Monad.Co
  • (Bind f, Bind g) => Bind (Product f g)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • (Bind f, Bind g) => Bind (f :*: g)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind f => Bind (M1 i c f)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind m => Bind (RWST r w s m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • (Bind m, Semigroup w) => Bind (RWST r w s m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class

    An RWST r w s m is not a Monad unless its w is a Monoid, but it is an instance of Bind

  • (Bind m, Semigroup w) => Bind (RWST r w s m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class

    An RWST r w s m is not a Monad unless its w is a Monoid, but it is an instance of Bind

newtypenewtype Compose (f :: k -> Type) (g :: k1 -> k) (a :: k1)
#

Right-to-left composition of functors. The composition of applicative functors is always applicative, but the composition of monads is not always a monad.

Examples
Example1 expression
fmap (subtract 1) (Compose (Just [1, 2, 3]))Compose (Just [0,1,2])
Example1 expression
Compose (Just [1, 2, 3]) <> Compose NothingCompose (Just [1,2,3])
Example1 expression
Compose (Just [(++ "World"), (++ "Haskell")]) <*> Compose (Just ["Hello, "])Compose (Just ["Hello, World","Hello, Haskell"])

Constructors

Instances74Generic1, TestEquality, Composition, FoldableWithIndex, FunctorWithIndex, TraversableWithIndex, …
classclass Contravariant (f :: Type -> Type) where
#

The class of contravariant functors.

Whereas in Haskell, one can think of a Functor as containing or producing values, a contravariant functor is a functor that can be thought of as consuming values.

As an example, consider the type of predicate functions a -> Bool. One such predicate might be negative x = x < 0, which classifies integers as to whether they are negative. However, given this predicate, we can re-use it in other situations, providing we have a way to map values to integers. For instance, we can use the negative predicate on a person's bank balance to work out if they are currently overdrawn:

newtype Predicate a = Predicate { getPredicate :: a -> Bool }

instance Contravariant Predicate where
  contramap :: (a' -> a) -> (Predicate a -> Predicate a')
  contramap f (Predicate p) = Predicate (p . f)
                                         |   `- First, map the input...
                                         `----- then apply the predicate.

overdrawn :: Predicate Person
overdrawn = contramap personBankBalance negative

Any instance should be subject to the following laws:

Identity

contramap id = id

Composition

contramap (g . f) = contramap f . contramap g

Note, that the second law follows from the free theorem of the type of contramap and the first law, so you need only check that the former condition holds.

Methods

  • contramap :: (a' -> a) -> f a -> f a'
  • (>$) :: b -> f b -> f ainfixl 4

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

Instances42Contravariant, …
classclass Contravariant f => Divisible (f :: Type -> Type) where
#

A Divisible contravariant functor is the contravariant analogue of Applicative.

Continuing the intuition that Contravariant functors consume input, a Divisible contravariant functor also has the ability to be composed "beside" another contravariant functor.

Serializers provide a good example of Divisible contravariant functors. To begin let's start with the type of serializers for specific types:

newtype Serializer a = Serializer { runSerializer :: a -> ByteString }

This is a contravariant functor:

instance Contravariant Serializer where
  contramap f s = Serializer (runSerializer s . f)

That is, given a serializer for a (s :: Serializer a), and a way to turn bs into as (a mapping f :: b -> a), we have a serializer for b: contramap f s :: Serializer b.

Divisible gives us a way to combine two serializers that focus on different parts of a structure. If we postulate the existance of two primitive serializers - string :: Serializer String and int :: Serializer Int, we would like to be able to combine these into a serializer for pairs of Strings and Ints. How can we do this? Simply run both serializers and combine their output!

data StringAndInt = StringAndInt String Int

stringAndInt :: Serializer StringAndInt
stringAndInt = Serializer $ \(StringAndInt s i) ->
  let sBytes = runSerializer string s
      iBytes = runSerializer int i
  in sBytes <> iBytes

divide is a generalization by also taking a contramap like function to split any a into a pair. This conveniently allows you to target fields of a record, for instance, by extracting the values under two fields and combining them into a tuple.

To complete the example, here is how to write stringAndInt using a Divisible instance:

instance Divisible Serializer where
  conquer = Serializer (const mempty)

  divide toBC bSerializer cSerializer = Serializer $ \a ->
    case toBC a of
      (b, c) ->
        let bBytes = runSerializer bSerializer b
            cBytes = runSerializer cSerializer c
        in bBytes <> cBytes

stringAndInt :: Serializer StringAndInt
stringAndInt =
  divide (\(StringAndInt s i) -> (s, i)) string int

Methods

  • divide :: (a -> (b, c)) -> f b -> f c -> f a
  • conquer :: f a

    Conquer acts as an identity for combining Divisible functors.

Instances32Divisible, …
classclass Functor w => Extend (w :: Type -> Type) where
#

Methods

  • duplicated :: w a -> w (w a)
    duplicated = extended id
    fmap (fmap f) . duplicated = duplicated . fmap f
  • extended :: (w a -> b) -> w a -> w b
    extended f  = fmap f . duplicated
Instances42Extend, …
classclass Invariant (f :: Type -> Type) where
#

Any * -> * type parametric in the argument permits an instance of Invariant.

Instances should satisfy the following laws:

invmap id id = id
invmap f2 f2' . invmap f1 f1' = invmap (f2 . f1) (f1' . f2')

Methods

  • invmap :: (a -> b) -> (b -> a) -> f a -> f b
Instances130Invariant, …
classclass Alt f => Plus (f :: Type -> Type) where
#

Laws:

zero <!> m = m
m <!> zero = m

If extended to an Alternative then zero should equal empty.

Methods

Instances41Plus, …
  • Plus IntMapDefined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus SeqDefined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus FirstDefined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus LastDefined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus MaybeDefined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus IODefined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Plus []Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Alternative f => Plus (WrappedApplicative f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • MonadPlus m => Plus (WrappedMonad m)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Ord k => Plus (Map k)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus ProxyDefined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus U1Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus f => Plus (Coyoneda f)Defined in kan-extensions-5.2.7 · Data.Functor.Coyoneda
  • Plus f => Plus (Yoneda f)Defined in kan-extensions-5.2.7 · Data.Functor.Yoneda
  • Plus f => Plus (Lift f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • (Functor f, Monad f) => Plus (MaybeT f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • (Hashable k, Eq k) => Plus (HashMap k)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • ArrowPlus a => Plus (WrappedArrow a b)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus f => Plus (Rec1 f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus f => Plus (Static f a)Defined in semigroupoids-6.0.1 · Data.Semigroupoid.Static
  • Plus f => Plus (Backwards f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus f => Plus (IdentityT f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus f => Plus (ReaderT e f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus f => Plus (StateT e f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus f => Plus (StateT e f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus f => Plus (WriterT w f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus f => Plus (WriterT w f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus f => Plus (WriterT w f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus f => Plus (Reverse f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • (Functor f, Monad f, Semigroup e, Monoid e) => Plus (ExceptT e f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Monoid c => Plus (K1 i c)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • (Plus f, Plus g) => Plus (Product f g)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • (Plus f, Plus g) => Plus (f :*: g)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • (v ~~ v', Plus v') => Plus (Codensity v)Defined in kan-extensions-5.2.7 · Control.Monad.Codensity
  • Plus f => Plus (M1 i c f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus f => Plus (RWST r w s f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus f => Plus (RWST r w s f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Plus f => Plus (RWST r w s f)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • (Plus f, Functor g) => Plus (Compose f g)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • (Plus f, Functor g) => Plus (f :.: g)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
newtypenewtype Sum a
#

Monoid under addition.

Sum a <> Sum b = Sum (a + b)
Examples
Example1 expression
Sum 1 <> Sum 2 <> memptySum {getSum = 3}
Example1 expression
mconcat [ Sum n | n <- [3 .. 9]]Sum {getSum = 42}

Constructors

Instances44Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
  • Monad SumDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Functor SumDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • MonadFix SumDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Monad.Fix
  • Applicative SumDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Foldable SumDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Foldable
  • Traversable SumDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Traversable
  • MonadZip SumDefined in base-4.20.2.0 · Control.Monad.Zip
  • Foldable1 SumDefined in base-4.20.2.0 · Data.Foldable1
  • NFData1 SumDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Distributive SumDefined in distributive-0.6.2.1 · Data.Distributive
  • Apply SumDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind SumDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Extend SumDefined in semigroupoids-6.0.1 · Data.Functor.Extend
  • Traversable1 SumDefined in semigroupoids-6.0.1 · Data.Semigroup.Traversable.Class
  • Representable SumDefined in adjunctions-4.4.3 · Data.Functor.Rep
  • Invariant SumDefined in invariant-0.6.4 · Data.Functor.Invariant
  • Copointed SumDefined in pointed-5.0.4 · Data.Copointed
  • Pointed SumDefined in pointed-5.0.4 · Data.Pointed
  • Generic1 SumDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Unbox a => Vector Vector (Sum a)Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Unbox a => MVector MVector (Sum a)Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Bounded a => Bounded (Sum 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
  • Data a => Data (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num a => Num (Sum 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
  • Read a => Read (Sum 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
  • Generic (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Num a => Semigroup (Sum 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
  • NFData a => NFData (Sum a)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • Binary a => Binary (Sum a)Defined in binary-0.8.9.3 · Data.Binary.Class
  • Prim a => Prim (Sum a)Defined in primitive-0.9.1.0 · Data.Primitive.Types
  • Unbox a => Unbox (Sum a)Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Num a => Default (Sum a)Defined in data-default-0.8.0.1 · Data.Default.Internal
  • Num a => Abelian (Sum a)Defined in groups-0.5.3 · Data.Group
  • Integral a => Cyclic (Sum a)Defined in groups-0.5.3 · Data.Group
  • Num a => Group (Sum a)Defined in groups-0.5.3 · Data.Group
  • type Rep (Sum a) = D1 ('MetaData "Sum" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Sum" 'PrefixI 'True) (S1 ('MetaSel ('Just "getSum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • type Rep1 Sum = D1 ('MetaData "Sum" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Sum" 'PrefixI 'True) (S1 ('MetaSel ('Just "getSum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • data MVector s (Sum a)Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector (Sum a)Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • type Rep Sum = ()Defined in adjunctions-4.4.3 · Data.Functor.Rep
classclass Monoid m => Group m where
#

A Group is a Monoid plus a function, invert, such that:

a <> invert a == mempty
invert a <> a == mempty

Methods

  • invert :: m -> m
  • (~~) :: m -> m -> minfixl 7

    Group subtraction: x ~~ y == x <> invert y

  • pow :: Integral x => m -> x -> m
    pow a n == a <> a <> ... <> a
     (n lots of a)

    If n is negative, the result is inverted.

Instances16Group, …
classclass Semigroupoid k1 => Groupoid (k1 :: k -> k -> Type) where
#

semigroupoid with inverses. This technically should be a category with inverses, except we need to use Ob to define the valid objects for the category

Methods

  • inv :: k1 a b -> k1 b a
Instances5Groupoid
classclass Eq a => Hashable a where
#

The class of types that can be converted to a hash value.

Minimal implementation: hashWithSalt.

Hashable is intended exclusively for use in in-memory data structures. . Hashable does not have a fixed standard. This allows it to improve over time. . Because it does not have a fixed standard, different computers or computers on different versions of the code will observe different hash values. As such, Hashable is not recommended for use other than in-memory datastructures. Specifically, Hashable is not intended for network use or in applications which persist hashed values. For stable hashing use named hashes: sha256, crc32, xxhash etc.

If you are looking for Hashable instance in time package, check time-compat

Methods

  • hashWithSalt :: Int -> a -> Intinfixl 0

    Return a hash value for the argument, using the given salt.

    The general contract of hashWithSalt is:

    • If two values are equal according to the == method, then applying the hashWithSalt method on each of the two values must produce the same integer result if the same salt is used in each case.

    • It is not required that if two values are unequal according to the == method, then applying the hashWithSalt method on each of the two values must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal values may improve the performance of hashing-based data structures.

    • This method can be used to compute different hash values for the same input by providing a different salt in each application of the method. This implies that any instance that defines hashWithSalt must make use of the salt in its implementation.

    • hashWithSalt may return negative Int values.

  • hash :: a -> Int

    Like hashWithSalt, but no salt is used. The default implementation uses hashWithSalt with some default salt. Instances might want to implement this method to provide a more efficient implementation than the default implementation.

Instances94Hashable, …
newtypenewtype HashSet a
#

A set of values. A set cannot contain duplicate values.

Instances18Foldable, Eq1, Ord1, Show1, NFData1, Hashable1, …
  • Foldable HashSetDefined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Eq1 HashSetDefined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Ord1 HashSetDefined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Show1 HashSetDefined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • NFData1 HashSetDefined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Hashable1 HashSetDefined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Lift a => Lift (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Hashable a => IsList (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Eq a => Eq (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal

    Note that, in the presence of hash collisions, equal HashSets may behave differently, i.e. extensionality may be violated:

    Example2 expressions
    data D = A | B deriving (Eq, Show)instance Hashable D where hashWithSalt salt _d = salt
    Example2 expressions
    x = fromList [A, B]y = fromList [B, A]
    Example3 expressions
    x == yTruetoList x[A,B]toList y[B,A]

    In general, the lack of extensionality can be observed with any function that depends on the key ordering, such as folds and traversals.

  • (Data a, Hashable a) => Data (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Ord a => Ord (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • (Hashable a, Read a) => Read (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Show a => Show (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Hashable a => Semigroup (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal

    <> = union

    O(n+m)

    To obtain good performance, the smaller set must be presented as the first argument.

    Examples
    Example1 expression
    fromList [1,2] <> fromList [2,3]fromList [1,2,3]
  • Hashable a => Monoid (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal

    mempty = empty

    mappend = union

    O(n+m)

    To obtain good performance, the smaller set must be presented as the first argument.

    Examples
    Example1 expression
    mappend (fromList [1,2]) (fromList [2,3])fromList [1,2,3]
  • NFData a => NFData (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Hashable a => Hashable (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • type Item (HashSet a) = aDefined in unordered-containers-0.2.21 · Data.HashSet.Internal
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 minBound and maxBound from the Bounded class.

Instances69Bounded, Enum, Integral, Data, Num, Read, …
datadata IntMap a
#

A map of integers to values a.

Instances39Functor, Foldable, Traversable, Eq1, Ord1, Read1, …
datadata IntSet
#

A set of integers.

Instances14IsList, Eq, Data, Ord, Read, Show, …
  • IsList IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Eq IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Data IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Ord IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Read IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Show IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Semigroup IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Monoid IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • NFData IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Binary IntSetDefined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable IntSetDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Default IntSetDefined in data-default-0.8.0.1 · Data.Default.Internal
  • Lift IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • type Item IntSet = KeyDefined in containers-0.7 · Data.IntSet.Internal
newtypenewtype IORef a
#

A mutable variable in the IO monad.

Example11 expressions
import GHC.Internal.Data.IORefr <- newIORef 0readIORef r0writeIORef r 1readIORef r1atomicWriteIORef r 2readIORef r2modifyIORef' r (+ 1)readIORef r3atomicModifyIORef' r (\a -> (a + 1, ()))readIORef r4

See also STRef and Control.Concurrent.MVar.MVar.

Instances6NFData1, Eq, NFData, HasGetter, HasSetter, HasUpdate
  • NFData1 IORefDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Eq (IORef a)Defined in ghc-internal-9.1003.0 · GHC.Internal.IORef

    Pointer equality.

  • NFData (IORef a)Defined in deepseq-1.5.0.0 · Control.DeepSeq

    NOTE: Only strict in the reference and not the referenced value.

  • HasGetter (IORef a) aDefined in StateVar-1.2.2 · Data.StateVar
  • HasSetter (IORef a) aDefined in StateVar-1.2.2 · Data.StateVar
  • HasUpdate (IORef a) a aDefined in StateVar-1.2.2 · Data.StateVar
classclass Ord a => Ix a where
#

The Ix class is used to map a contiguous subrange of values in a type onto integers. It is used primarily for array indexing (see the array package).

The first argument (l,u) of each of these operations is a pair specifying the lower and upper bounds of a contiguous subrange of values.

An implementation is entitled to assume the following laws about these operations:

Methods

  • range :: (a, a) -> [a]

    The list of values in the subrange defined by a bounding pair.

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

    The position of a subscript in the subrange.

  • inRange :: (a, a) -> a -> Bool

    Returns True the given subscript lies in the range defined the bounding pair.

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

    The size of the subrange defined by a bounding pair.

Instances92Ix, …
  • Ix IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Ix NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Ix VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Ix CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Ix IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Ix WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Ix AssociativityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ix DecidedStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ix SourceStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ix SourceUnpackednessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ix SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Ix IOModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.IOMode
  • Ix Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ix Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ix Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ix Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ix CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Ix GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.Unicode
  • Ix Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ix Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ix Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ix Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ix BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Ix CharDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Ix IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Ix OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Ix WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Ix DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • Ix MonthDefined in time-1.12.2 · Data.Time.Calendar.Month
  • Ix QuarterDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Ix QuarterOfYearDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Ix DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Ix ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Ix a => Ix (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Ix a => Ix (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Ix a => Ix (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Ix (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • (Ix a, Ix b) => Ix (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Ix a => Ix (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Ix b => Ix (Tagged s b)Defined in tagged-0.8.9 · Data.Tagged
  • (Ix a1, Ix a2, Ix a3) => Ix (a1, a2, a3)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • (Ix a1, Ix a2, Ix a3, Ix a4) => Ix (a1, a2, a3, a4)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5) => Ix (a1, a2, a3, a4, a5)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6) => Ix (a1, a2, a3, a4, a5, a6)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7) => Ix (a1, a2, a3, a4, a5, a6, a7)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8) => Ix (a1, a2, a3, a4, a5, a6, a7, a8)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8, Ix a9) => Ix (a1, a2, a3, a4, a5, a6, a7, a8, a9)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8, Ix a9, Ix aA) => Ix (a1, a2, a3, a4, a5, a6, a7, a8, a9, aA)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8, Ix a9, Ix aA, Ix aB) => Ix (a1, a2, a3, a4, a5, a6, a7, a8, a9, aA, aB)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8, Ix a9, Ix aA, Ix aB, Ix aC) => Ix (a1, a2, a3, a4, a5, a6, a7, a8, a9, aA, aB, aC)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8, Ix a9, Ix aA, Ix aB, Ix aC, Ix aD) => Ix (a1, a2, a3, a4, a5, a6, a7, a8, a9, aA, aB, aC, aD)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8, Ix a9, Ix aA, Ix aB, Ix aC, Ix aD, Ix aE) => Ix (a1, a2, a3, a4, a5, a6, a7, a8, a9, aA, aB, aC, aD, aE)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5, Ix a6, Ix a7, Ix a8, Ix a9, Ix aA, Ix aB, Ix aC, Ix aD, Ix aE, Ix aF) => Ix (a1, a2, a3, a4, a5, a6, a7, a8, a9, aA, aB, aC, aD, aE, aF)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ix
datadata List a
#

The builtin linked list type.

In Haskell, lists are one of the most important data types as they are often used analogous to loops in imperative programming languages. These lists are singly linked, which makes them unsuited for operations that require \mathcal{O}(1) access. Instead, they are intended to be traversed.

You can use List a or [a] in type signatures:

length :: [a] -> Int

or

length :: List a -> Int

They are fully equivalent, and List a will be normalised to [a].

Usage

Lists are constructed recursively using the right-associative constructor operator (or cons) (:) :: a -> [a] -> [a], which prepends an element to a list, and the empty list [].

(1 : 2 : 3 : []) == (1 : (2 : (3 : []))) == [1, 2, 3]

Lists can also be constructed using list literals of the form [x_1, x_2, ..., x_n] which are syntactic sugar and, unless -XOverloadedLists is enabled, are translated into uses of (:) and []

String literals, like "I 💜 hs", are translated into Lists of characters, ['I', ' ', '💜', ' ', 'h', 's'].

Implementation

Internally and in memory, all the above are represented like this, with arrows being pointers to locations in memory.

╭───┬───┬──╮   ╭───┬───┬──╮   ╭───┬───┬──╮   ╭────╮
│(:)│   │ ─┼──>│(:)│   │ ─┼──>│(:)│   │ ─┼──>│ [] │
╰───┴─┼─┴──╯   ╰───┴─┼─┴──╯   ╰───┴─┼─┴──╯   ╰────╯
      v              v              v
      1              2              3
Examples
>>> ['H', 'a', 's', 'k', 'e', 'l', 'l']
"Haskell"
>>> 1 : [4, 1, 5, 9]
[1,4,1,5,9]
>>> [] : [] : []
[[],[]]
Instances73Monad, Functor, MonadFix, MonadFail, Applicative, Foldable, …
datadata NonEmpty a
#

Non-empty (and non-strict) list type.

Constructors

  • a :| [a]infixr 5
Instances57Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
datadata Map k a
#

A Map from keys k to values a.

The Semigroup operation for Map is union, which prefers values from the left operand. If m1 maps a key k to a value a1, and m2 maps the same key to a different value a2, then their union m1 <> m2 maps k to a1.

Instances45Bifoldable, Eq2, Ord2, Show2, Hashable2, FoldableWithIndex, …
  • Bifoldable MapDefined in containers-0.7 · Data.Map.Internal
  • Eq2 MapDefined in containers-0.7 · Data.Map.Internal
  • Ord2 MapDefined in containers-0.7 · Data.Map.Internal
  • Show2 MapDefined in containers-0.7 · Data.Map.Internal
  • Hashable2 MapDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • FoldableWithIndex k (Map k)Defined in indexed-traversable-0.1.4 · WithIndex
  • FunctorWithIndex k (Map k)Defined in indexed-traversable-0.1.4 · WithIndex
  • TraversableWithIndex k (Map k)Defined in indexed-traversable-0.1.4 · WithIndex
  • (Lift k, Lift a) => Lift (Map k a)Defined in containers-0.7 · Data.Map.Internal
  • Functor (Map k)Defined in containers-0.7 · Data.Map.Internal
  • Foldable (Map k)Defined in containers-0.7 · Data.Map.Internal

    Folds in order of increasing key.

  • Traversable (Map k)Defined in containers-0.7 · Data.Map.Internal

    Traverses in order of increasing key.

  • Eq k => Eq1 (Map k)Defined in containers-0.7 · Data.Map.Internal
  • Ord k => Ord1 (Map k)Defined in containers-0.7 · Data.Map.Internal
  • (Ord k, Read k) => Read1 (Map k)Defined in containers-0.7 · Data.Map.Internal
  • Show k => Show1 (Map k)Defined in containers-0.7 · Data.Map.Internal
  • Hashable k => Hashable1 (Map k)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Ord k => Alt (Map k)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Ord k => Apply (Map k)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class

    A 'Map k' is not Applicative, but it is an instance of Apply

  • Ord k => Bind (Map k)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class

    A 'Map k' is not a Monad, but it is an instance of Bind

  • Ord k => Plus (Map k)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Invariant (Map k)Defined in invariant-0.6.4 · Data.Functor.Invariant

    from the containers package

  • Ord k => Adjustable (Map k)Defined in keys-3.12.3 · Data.Key
  • FoldableWithKey (Map k)Defined in keys-3.12.3 · Data.Key
  • Ord k => Indexable (Map k)Defined in keys-3.12.3 · Data.Key
  • Keyed (Map k)Defined in keys-3.12.3 · Data.Key
  • Ord k => Lookup (Map k)Defined in keys-3.12.3 · Data.Key
  • TraversableWithKey (Map k)Defined in keys-3.12.3 · Data.Key
  • Ord k => Zip (Map k)Defined in keys-3.12.3 · Data.Key
  • Ord k => ZipWithKey (Map k)Defined in keys-3.12.3 · Data.Key
  • Default k => Pointed (Map k)Defined in pointed-5.0.4 · Data.Pointed
  • Ord k => IsList (Map k v)Defined in containers-0.7 · Data.Map.Internal
  • (Eq k, Eq a) => Eq (Map k a)Defined in containers-0.7 · Data.Map.Internal
  • (Data k, Data a, Ord k) => Data (Map k a)Defined in containers-0.7 · Data.Map.Internal
  • (Ord k, Ord v) => Ord (Map k v)Defined in containers-0.7 · Data.Map.Internal
  • (Ord k, Read k, Read e) => Read (Map k e)Defined in containers-0.7 · Data.Map.Internal
  • (Show k, Show a) => Show (Map k a)Defined in containers-0.7 · Data.Map.Internal
  • Ord k => Semigroup (Map k v)Defined in containers-0.7 · Data.Map.Internal
  • Ord k => Monoid (Map k v)Defined in containers-0.7 · Data.Map.Internal
  • (NFData k, NFData a) => NFData (Map k a)Defined in containers-0.7 · Data.Map.Internal
  • (Binary k, Binary e) => Binary (Map k e)Defined in binary-0.8.9.3 · Data.Binary.Class
  • (Hashable k, Hashable v) => Hashable (Map k v)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Default (Map k v)Defined in data-default-0.8.0.1 · Data.Default.Internal
  • type Item (Map k v) = (k, v)Defined in containers-0.7 · Data.Map.Internal
  • type Key (Map k) = kDefined in keys-3.12.3 · Data.Key
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!"
Instances103Monoid, …
  • Monoid ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • Monoid BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.Internal
  • Monoid ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Monoid ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • Monoid ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • Monoid IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Monoid AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Monoid EventLifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Monoid LifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types

    mappend takes the longer of two lifetimes.

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

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

  • Monoid PosixStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Monoid WindowsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Monoid DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJ
  • Monoid TextDefined in text-2.1.3 · Data.Text · orphan
  • Monoid BuilderDefined in text-2.1.3 · Data.Text.Internal.Builder
  • Monoid TextDefined in text-2.1.3 · Data.Text.Lazy · orphan
  • Monoid StrictTextBuilderDefined in text-2.1.3 · Data.Text.Internal.StrictBuilder
  • Monoid CalendarDiffDaysDefined in time-1.12.2 · Data.Time.Calendar.CalendarDiffDays

    Additive

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

    Additive

  • Monoid ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid (Comparison a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

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

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

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

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

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

    mempty :: Predicate a
    mempty = _ -> True
    
  • Monoid (PutM ())Defined in binary-0.8.9.3 · Data.Binary.Put
  • Monoid (IntMap a)Defined in containers-0.7 · Data.IntMap.Internal
  • Monoid (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Monoid (MergeSet a)Defined in containers-0.7 · Data.Set.Internal
  • Monoid (DList a)Defined in dlist-1.0 · Data.DList.Internal
  • Monoid (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monoid (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monoid (Endo a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Monoid (Array a)Defined in primitive-0.9.1.0 · Data.Primitive.Array
  • Monoid (PrimArray a)Defined in primitive-0.9.1.0 · Data.Primitive.PrimArray
  • Monoid (SmallArray a)Defined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • Monoid (Validity k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal.Debug
  • Monoid (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Monoid (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Strict
  • Monoid [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid a => Monoid (STM a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Monoid a => Monoid (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Monoid a => Monoid (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Monoid a => Monoid (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid a => Monoid (IO a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid a => Monoid (Q a)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Monoid a => Monoid (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid m => Monoid (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Monoid p => Monoid (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Semigroup a => Monoid (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base

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

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

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

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

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

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

  • Storable a => Monoid (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Storable
  • 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 (Set a)Defined in containers-0.7 · Data.Set.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
  • Hashable a => Monoid (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal

    mempty = empty

    mappend = union

    O(n+m)

    To obtain good performance, the smaller set must be presented as the first argument.

    Examples
    Example1 expression
    mappend (fromList [1,2]) (fromList [2,3])fromList [1,2,3]
  • Prim a => Monoid (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Primitive
  • Unbox a => Monoid (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Unboxed · orphan
  • (Generic a, Monoid (Rep a ())) => Monoid (Generically a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Generic a, GMonoid (Rep a)) => Monoid (GenericSemigroupMonoid a)Defined in semigroups-0.20 · Data.Semigroup.Generic
  • (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 (Alt f a)Defined in free-5.2 · Control.Alternative.Free
  • Monoid (Alt f a)Defined in free-5.2 · Control.Alternative.Free.Final
  • 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 e => Monoid (Validation e a)Defined in either-5.0.3 · Data.Either.Validation
  • Ord k => Monoid (Map k v)Defined in containers-0.7 · Data.Map.Internal
  • Hashable k => Monoid (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal

    mempty = empty

    mappend = union

    If a key occurs in both maps, the mapping from the first will be the mapping in the result.

    Examples
    Example1 expression
    mappend (fromList [(1,'a'),(2,'b')]) (fromList [(2,'c'),(3,'d')])fromList [(1,'a'),(2,'b'),(3,'d')]
  • (Monad m, Semigroup a, Monoid a) => Monoid (IterT m a)Defined in free-5.2 · Control.Monad.Trans.Iter
  • (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
  • Applicative f => Monoid (Traversed a f)Defined in indexed-traversable-0.1.4 · WithIndex
  • Monad m => Monoid (Sequenced a m)Defined in indexed-traversable-0.1.4 · WithIndex
  • Monoid (f p) => Monoid (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monoid a => Monoid (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Monoid a => Monoid (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • ArrowPlus p => Monoid (Tambara p a b)Defined in profunctors-5.6.3 · Data.Profunctor.Strong
  • (Biapplicative bi, Monoid a, Monoid b) => Monoid (Biap bi a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biap
  • (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
  • (Semigroup a, Monoid a) => Monoid (Tagged s a)Defined in tagged-0.8.9 · Data.Tagged
  • (Profunctor p, Arrow p, Semigroup b, Monoid b) => Monoid (Closure p a b)Defined in profunctors-5.6.3 · Data.Profunctor.Closed
  • Monoid c => Monoid (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monoid r => Monoid (Forget r a b)Defined in profunctors-5.6.3 · Data.Profunctor.Types

    Via Monoid r => (a -> r)

  • (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
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

Instances352Ord, …
  • 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 OptionsDefined in bifunctors-5.6.2 · Data.Bifunctor.TH
  • Ord ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Ord ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • Ord ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal

    Lexicographic order.

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

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

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

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

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

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

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

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

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

  • Ord IntDefined in ghc-prim-0.12.0 · GHC.Classes
  • Ord OrderingDefined in ghc-prim-0.12.0 · GHC.Classes
  • Ord TyConDefined in ghc-prim-0.12.0 · GHC.Classes
  • Ord WordDefined in ghc-prim-0.12.0 · GHC.Classes
  • Ord OptionsDefined in invariant-0.6.4 · Data.Functor.Invariant.TH
  • Ord InvariantClassDefined in invariant-0.6.4 · Data.Functor.Invariant.TH.Internal
  • Ord OsCharDefined in os-string-2.0.7 · System.OsString.Internal.Types

    Byte ordering of the internal representation.

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

    Byte ordering of the internal representation.

  • Ord PosixCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Ord PosixStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Ord WindowsCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Ord WindowsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Ord PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Ord PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Ord CardinalityDefined in random-1.2.1.3 · System.Random.GFinite
  • Ord ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    Scientific numbers can be safely compared for ordering. No magnitude 10^e is calculated so there's no risk of a blowup in space or time when comparing scientific numbers coming from untrusted sources.

  • Ord AnnLookupDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord AnnTargetDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord BangDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord BndrVisDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord BodyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord BytesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord CallconvDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord ClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord ConDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord DecDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord DecidedStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord DerivClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord DerivStrategyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord DocLocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord ExpDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord FamilyResultSigDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord FixityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord FixityDirectionDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord ForeignDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord FunDepDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord GuardDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord InfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord InjectivityAnnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord InlineDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord LitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord LocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord MatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord ModNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord ModuleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord ModuleInfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord NameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord NameFlavourDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord NameSpaceDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord NamespaceSpecifierDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord OccNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord OverlapDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord PatDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord PatSynArgsDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord PatSynDirDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord PhasesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord PkgNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord PragmaDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord RangeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord RoleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord RuleBndrDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord RuleMatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord SafetyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord SourceStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord SourceUnpackednessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord SpecificityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord StmtDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord TyLitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord TySynEqnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord TypeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord TypeFamilyHeadDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord I8Defined in text-2.1.3 · Data.Text.Foreign
  • Ord TextDefined in text-2.1.3 · Data.Text · orphan
  • Ord BuilderDefined in text-2.1.3 · Data.Text.Internal.Builder
  • Ord TextDefined in text-2.1.3 · Data.Text.Lazy · orphan
  • Ord ConstructorVariantDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Ord DatatypeVariantDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Ord FieldStrictnessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Ord StrictnessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Ord UnpackednessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Ord DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • Ord MonthDefined in time-1.12.2 · Data.Time.Calendar.Month
  • Ord QuarterDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Ord QuarterOfYearDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Ord DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Ord AbsoluteTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.AbsoluteTime
  • Ord DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Ord NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Ord SystemTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.SystemTime
  • Ord UTCTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UTCTime
  • Ord UniversalTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UniversalTime
  • Ord TimeLocaleDefined in time-1.12.2 · Data.Time.Format.Locale
  • Ord LocalTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.LocalTime
  • Ord TimeOfDayDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeOfDay
  • Ord TimeZoneDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeZone
  • Ord UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Ord UnpackedUUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Ord ()Defined in ghc-prim-0.12.0 · GHC.Classes
  • Integral a => Ord (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Ord (ConstPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.ConstPtr
  • Ord (ForeignPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ForeignPtr
  • Ord (FunPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Ord (Ptr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Ord (SChar c)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Ord (SSymbol s)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Ord (SNat n)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • Ord a => Ord (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Ord a => Ord (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Ord a => Ord (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Ord a => Ord (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Ord a => Ord (IntMap a)Defined in containers-0.7 · Data.IntMap.Internal
  • Ord a => Ord (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Ord a => Ord (ViewL a)Defined in containers-0.7 · Data.Sequence.Internal
  • Ord a => Ord (ViewR a)Defined in containers-0.7 · Data.Sequence.Internal
  • Ord a => Ord (Intersection a)Defined in containers-0.7 · Data.Set.Internal
  • Ord a => Ord (Set a)Defined in containers-0.7 · Data.Set.Internal
  • Ord a => Ord (Tree a)Defined in containers-0.7 · Data.Tree
  • Ord a => Ord (DNonEmpty a)Defined in dlist-1.0 · Data.DList.DNonEmpty.Internal
  • Ord a => Ord (DList a)Defined in dlist-1.0 · Data.DList.Internal
  • 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 (Hashed a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Ord a => Ord (Array a)Defined in primitive-0.9.1.0 · Data.Primitive.Array

    Lexicographic ordering. Subject to change between major versions.

  • Ord a => Ord (SmallArray a)Defined in primitive-0.9.1.0 · Data.Primitive.SmallArray

    Lexicographic ordering. Subject to change between major versions.

  • Ord a => Ord (Stream a)Defined in text-2.1.3 · Data.Text.Internal.Fusion.Types
  • Ord a => Ord (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Ord a => Ord (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Ord a => Ord (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Strict
  • Ord a => Ord (a)Defined in ghc-prim-0.12.0 · GHC.Classes
  • Ord a => Ord [a]Defined in ghc-prim-0.12.0 · GHC.Classes
  • Ord flag => Ord (TyVarBndr flag)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Ord g => Ord (StateGen g)Defined in random-1.2.1.3 · System.Random.Internal
  • Ord g => Ord (AtomicGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Ord g => Ord (IOGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Ord g => Ord (STGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Ord g => Ord (TGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • 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
  • (Storable a, Ord a) => Ord (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Storable
  • (Ord a, Prim a) => Ord (PrimArray a)Defined in primitive-0.9.1.0 · Data.Primitive.PrimArray

    Lexicographic ordering. Subject to change between major versions.

  • (Prim a, Ord a) => Ord (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Primitive
  • (Unbox a, Ord a) => Ord (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Unboxed · orphan
  • 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 m => Ord (Over m a)Defined in selective-0.7.0.1 · Control.Selective
  • Ord m => Ord (Under m a)Defined in selective-0.7.0.1 · Control.Selective
  • Ord m => Ord (Over m a)Defined in selective-0.7.0.1 · Control.Selective.Multi
  • Ord m => Ord (Under m a)Defined in selective-0.7.0.1 · Control.Selective.Multi
  • (Ord1 f, Ord a) => Ord (Ap f a)Defined in free-5.2 · Control.Applicative.Free
  • (Ord1 f, Ord a) => Ord (Cofree f a)Defined in free-5.2 · Control.Comonad.Cofree
  • (Ord1 f, Ord a) => Ord (Free f a)Defined in free-5.2 · Control.Monad.Free
  • (Ord1 f, Ord a) => Ord (Free f a)Defined in free-5.2 · Control.Monad.Free.Ap
  • (Ord1 f, Ord a) => Ord (Coyoneda f a)Defined in kan-extensions-5.2.7 · Data.Functor.Coyoneda
  • (Ord1 f, Ord a) => Ord (Yoneda f a)Defined in kan-extensions-5.2.7 · Data.Functor.Yoneda
  • (Ord1 f, Ord a) => Ord (Lift f a)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • (Ord1 m, Ord a) => Ord (IterT m a)Defined in free-5.2 · Control.Monad.Trans.Iter
  • (Ord1 m, Ord a) => Ord (MaybeT m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • (Ord1 w, Ord a) => Ord (CoiterT w a)Defined in free-5.2 · Control.Comonad.Trans.Coiter
  • (Ix i, Ord e) => Ord (Array i e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Arr
  • (Ix ix, Ord e, IArray UArray e) => Ord (UArray ix e)Defined in array-0.5.8.0 · Data.Array.Base
  • (Ord a, Ord b) => Ord (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either
  • (Ord a, Ord b) => Ord (a, b)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Ord e, Ord a) => Ord (Validation e a)Defined in either-5.0.3 · Data.Either.Validation
  • (Ord e, Ord a) => Ord (Validation e a)Defined in selective-0.7.0.1 · Control.Selective
  • (Ord k, Ord v) => Ord (Map k v)Defined in containers-0.7 · Data.Map.Internal
  • (Ord k, Ord v) => Ord (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal

    The ordering is total and consistent with the Eq instance. However, nothing else about the ordering is specified, and it may change from version to version of either this package or of hashable.

  • (GOrd (Rep1 f a), Generic1 f) => Ord (FunctorClassesDefault f a)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • 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 (bi a b) => Ord (Biap bi a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biap
  • 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 a) => Ord (WrappedContravariant f a)Defined in invariant-0.6.4 · Data.Functor.Invariant
  • Ord (f a) => Ord (WrappedFunctor f a)Defined in invariant-0.6.4 · Data.Functor.Invariant
  • Ord (f p) => Ord (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (p (Fix p a) a) => Ord (Fix p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Fix
  • Ord (p a a) => Ord (Join p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Join
  • Ord (w (CofreeF f a (CofreeT f w a))) => Ord (CofreeT f w a)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • Ord a => Ord (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Ord a => Ord (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • Ord a => Ord (Bundle Id v a)Defined in vector-0.13.2.0 · Data.Vector.Fusion.Bundle · orphan
  • Ord b => Ord (Tagged s b)Defined in tagged-0.8.9 · Data.Tagged
  • (Ord1 f, Ord1 m, Ord a) => Ord (FreeT f m a)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Ord1 f, Ord1 m, Ord a) => Ord (FreeT f m a)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Ord1 f, Ord a) => Ord (Backwards f a)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • (Ord1 f, Ord a) => Ord (IdentityT f a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • (Ord1 f, Ord a) => Ord (Reverse f a)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • (Ord1 f, Ord e, Ord a) => Ord (ExceptT e f a)Defined in selective-0.7.0.1 · Control.Selective.Trans.Except
  • (Functor f, Monad m, Ord1 f, Ord1 m, Ord a) => Ord (FT f m a)Defined in free-5.2 · Control.Monad.Trans.Free.Church
  • (Generic1 f, Ord (Rep1 f a)) => Ord (Generically1 f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Ord a, Ord (f b)) => Ord (CofreeF f a b)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • (Ord a, Ord (f b)) => Ord (FreeF f a b)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Ord a, Ord (f b)) => Ord (FreeF f a b)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Ord a, Ord b, Ord c) => Ord (a, b, c)Defined in ghc-prim-0.12.0 · GHC.Classes
  • (Ord e, Ord1 m, Ord a) => Ord (ExceptT e m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • (Ord w, Ord1 m, Ord a) => Ord (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Ord w, Ord1 m, Ord a) => Ord (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • Ord (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Ord c => Ord (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Ord (f a), Ord (g a)) => Ord (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Ord (f a), Ord (g a)) => Ord (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Ord (f p), Ord (g p)) => Ord ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Ord (f p), Ord (g p)) => Ord ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Ord a, Ord b, Ord c, Ord d) => Ord (a, b, c, d)Defined in ghc-prim-0.12.0 · GHC.Classes
  • Ord (f (g a)) => Ord (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Ord (f (g p)) => Ord ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (f a) => Ord (Clown f a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Clown
  • Ord (f p) => Ord (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (g b) => Ord (Joker g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Joker
  • Ord (p a b) => Ord (WrappedBifunctor p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Wrapped
  • Ord (p a b) => Ord (WrappedProfunctor p a b)Defined in invariant-0.6.4 · Data.Functor.Invariant
  • Ord (p b a) => Ord (Flip p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Flip
  • (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 (f a b), Ord (g a b)) => Ord (Product f g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Product
  • (Ord (p a b), Ord (q a b)) => Ord (Sum p q a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Sum
  • (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 (f (p a b)) => Ord (Tannen f p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Tannen
  • (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 (p (f a) (g b)) => Ord (Biff p f g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biff
  • (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 Profunctor (p :: Type -> Type -> Type) where
#

Formally, the class Profunctor represents a profunctor from Hask -> Hask.

Intuitively it is a bifunctor where the first argument is contravariant and the second argument is covariant.

You can define a Profunctor by either defining dimap or by defining both lmap and rmap.

If you supply dimap, you should ensure that:

dimap id id ≡ id

If you supply lmap and rmap, ensure:

lmap id ≡ id
rmap id ≡ id

If you supply both, you should also ensure:

dimap f g ≡ lmap f . rmap g

These ensure by parametricity:

dimap (f . g) (h . i) ≡ dimap g h . dimap f i
lmap (f . g) ≡ lmap g . lmap f
rmap (f . g) ≡ rmap f . rmap g

Methods

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

    Map over both arguments at the same time.

    dimap f g ≡ lmap f . rmap g
  • lmap :: (a -> b) -> p b c -> p a c

    Map the first argument contravariantly.

    lmap f ≡ dimap f id
  • rmap :: (b -> c) -> p a b -> p a c

    Map the second argument covariantly.

    rmap ≡ dimap id
  • (#.) :: Coercible c b => q b c -> p a b -> p a cinfixr 9

    Strictly map the second argument argument covariantly with a function that is assumed operationally to be a cast, such as a newtype constructor.

    Note: This operation is explicitly unsafe since an implementation may choose to use unsafeCoerce to implement this combinator and it has no way to validate that your function meets the requirements.

    If you implement this combinator with unsafeCoerce, then you are taking upon yourself the obligation that you don't use GADT-like tricks to distinguish values.

    If you import Data.Profunctor.Unsafe you are taking upon yourself the obligation that you will only call this with a first argument that is operationally identity.

    The semantics of this function with respect to bottoms should match the default definition:

    (Profuctor.Unsafe.#.) ≡ \_ -> \p -> p `seq` rmap coerce p
  • (.#) :: Coercible b a => p b c -> q a b -> p a cinfixl 8

    Strictly map the first argument argument contravariantly with a function that is assumed operationally to be a cast, such as a newtype constructor.

    Note: This operation is explicitly unsafe since an implementation may choose to use unsafeCoerce to implement this combinator and it has no way to validate that your function meets the requirements.

    If you implement this combinator with unsafeCoerce, then you are taking upon yourself the obligation that you don't use GADT-like tricks to distinguish values.

    If you import Data.Profunctor.Unsafe you are taking upon yourself the obligation that you will only call this with a second argument that is operationally identity.

    (.#) ≡ \p -> p `seq` \f -> lmap coerce p
Instances38Profunctor, …
newtypenewtype Cayley (f :: k -> Type) (p :: k1 -> k2 -> k) (a :: k1) (b :: k2)
#

Static arrows. Lifted by Applicative.

Cayley has a polymorphic kind since 5.6.

Constructors

Instances18ProfunctorFunctor, Category, ProfunctorComonad, ProfunctorMonad, Arrow, ArrowChoice, …
classclass Profunctor p => Choice (p :: Type -> Type -> Type) where
#

The generalization of Costar of Functor that is strong with respect to Either.

Note: This is also a notion of strength, except with regards to another monoidal structure that we can choose to equip Hask with: the cocartesian coproduct.

Methods

Instances23Choice, …
classclass Profunctor p => Closed (p :: Type -> Type -> Type) where
#

A strong profunctor allows the monoidal structure to pass through.

A closed profunctor allows the closed structure to pass through.

Methods

Instances18Closed, …
classclass (Traversing p, Closed p) => Mapping (p :: Type -> Type -> Type) where
#

Methods

Instances11Mapping, …
newtypenewtype Ran (p :: k -> k1 -> Type) (q :: k -> k2 -> Type) (a :: k1) (b :: k2)
#

This represents the right Kan extension of a Profunctor q along a Profunctor p in a limited version of the 2-category of Profunctors where the only object is the category Hask, 1-morphisms are profunctors composed and compose with Profunctor composition, and 2-morphisms are just natural transformations.

Ran has a polymorphic kind since 5.6.

Constructors

Instances7ProfunctorFunctor, Category, ProfunctorComonad, Profunctor, Invariant2, Functor, …
classclass (Sieve p (Rep p), Strong p) => Representable (p :: Type -> Type -> Type) where
#

A Profunctor p is Representable if there exists a Functor f such that p d c is isomorphic to d -> f c.

Associated types

Methods

Instances5Representable
familytype family Rep (p :: Type -> Type -> Type) :: Type -> Type
#
Instances5Rep
  • type Rep (Kleisli m) = mDefined in profunctors-5.6.3 · Data.Profunctor.Rep
  • type Rep (->) = IdentityDefined in profunctors-5.6.3 · Data.Profunctor.Rep
  • type Rep (Procompose p q) = Compose (Rep q) (Rep p)Defined in profunctors-5.6.3 · Data.Profunctor.Composition
  • type Rep (Forget r) = Const rDefined in profunctors-5.6.3 · Data.Profunctor.Rep
  • type Rep (Star f) = fDefined in profunctors-5.6.3 · Data.Profunctor.Rep
classclass (Profunctor p, Functor f) => Sieve (p :: Type -> Type -> Type) (f :: Type -> Type) | p -> f where
#

A Profunctor p is a Sieve on f if it is a subprofunctor of Star f.

That is to say it is a subset of Hom(-,f=) closed under lmap and rmap.

Alternately, you can view it as a sieve in the comma category Hask/f.

Methods

  • sieve :: p a b -> a -> f b
Instances5Sieve
classclass Profunctor p => Strong (p :: Type -> Type -> Type) where
#

Generalizing Star of a strong Functor

Note: Every Functor in Haskell is strong with respect to (,).

This describes profunctor strength with respect to the product structure of Hask.

http://www.riec.tohoku.ac.jp/~asada/papers/arrStrMnd.pdf

Methods

Instances21Strong, …
classclass (Choice p, Strong p) => Traversing (p :: Type -> Type -> Type) where
#

Note: Definitions in terms of wander are much more efficient!

Methods

Instances14Traversing, …
newtypenewtype Yoneda (p :: Type -> Type -> Type) a b
#

This is the cofree profunctor given a data constructor of kind * -> * -> *

Constructors

Instances15ProfunctorComonad, ProfunctorMonad, ProfunctorFunctor, Category, Choice, Cochoice, …
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
Instances66Generic1, FoldableWithIndex, FunctorWithIndex, TraversableWithIndex, Monad, Functor, …
  • Generic1 ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • FoldableWithIndex Void ProxyDefined in indexed-traversable-0.1.4 · WithIndex
  • FunctorWithIndex Void ProxyDefined in indexed-traversable-0.1.4 · WithIndex
  • TraversableWithIndex Void ProxyDefined in indexed-traversable-0.1.4 · WithIndex
  • 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
  • NFData1 ProxyDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Hashable1 ProxyDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Distributive ProxyDefined in distributive-0.6.2.1 · Data.Distributive
  • Decidable ProxyDefined in contravariant-1.5.5 · Data.Functor.Contravariant.Divisible
  • Divisible ProxyDefined in contravariant-1.5.5 · Data.Functor.Contravariant.Divisible
  • Alt ProxyDefined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Apply ProxyDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind ProxyDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Extend ProxyDefined in semigroupoids-6.0.1 · Data.Functor.Extend
  • Conclude ProxyDefined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Conclude
  • Decide ProxyDefined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Decide
  • Divise ProxyDefined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Divise
  • Plus ProxyDefined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Representable ProxyDefined in adjunctions-4.4.3 · Data.Functor.Rep
  • Representable ProxyDefined in adjunctions-4.4.3 · Data.Functor.Contravariant.Rep
  • Invariant ProxyDefined in invariant-0.6.4 · Data.Functor.Invariant
  • Selective ProxyDefined in selective-0.7.0.1 · Control.Selective
  • Adjustable ProxyDefined in keys-3.12.3 · Data.Key
  • FoldableWithKey ProxyDefined in keys-3.12.3 · Data.Key
  • Indexable ProxyDefined in keys-3.12.3 · Data.Key
  • Keyed ProxyDefined in keys-3.12.3 · Data.Key
  • Lookup ProxyDefined in keys-3.12.3 · Data.Key
  • TraversableWithKey ProxyDefined in keys-3.12.3 · Data.Key
  • Zip ProxyDefined in keys-3.12.3 · Data.Key
  • ZipWithKey ProxyDefined in keys-3.12.3 · Data.Key
  • Pointed ProxyDefined in pointed-5.0.4 · Data.Pointed
  • Cosieve Tagged ProxyDefined in profunctors-5.6.3 · Data.Profunctor.Sieve
  • 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
  • NFData (Proxy a)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • Hashable (Proxy a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Default (Proxy a)Defined in data-default-0.8.0.1 · Data.Default.Internal
  • Abelian (Proxy x)Defined in groups-0.5.3 · Data.Group
  • Cyclic (Proxy x)Defined in groups-0.5.3 · Data.Group
  • Group (Proxy x)Defined in groups-0.5.3 · Data.Group

    Trivial group, Functor style.

  • 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
  • type Rep Proxy = VoidDefined in adjunctions-4.4.3 · Data.Functor.Rep
  • type Rep Proxy = ()Defined in adjunctions-4.4.3 · Data.Functor.Contravariant.Rep
  • type Key Proxy = VoidDefined in keys-3.12.3 · Data.Key
datadata Ratio a
#

Rational numbers, with numerator and denominator of some Integral type.

Note that Ratio's instances inherit the deficiencies from the type parameter's. For example, Ratio Natural's Num instance has similar problems to Numeric.Natural.Natural's.

Instances17NFData1, Lift, Enum, Eq, Fractional, Data, …
classclass Semigroup a where
#

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

Instances should satisfy the following:

Associativity

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

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

Unit

sconcat (pure x) = x

Multiplication

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

Methods

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

    An associative operation.

    Examples
    Example1 expression
    [1,2,3] <> [4,5,6][1,2,3,4,5,6]
    Example1 expression
    Just [1, 2, 3] <> Just [4, 5, 6]Just [1,2,3,4,5,6]
    Example1 expression
    putStr "Hello, " <> putStrLn "World!"Hello, World!
  • sconcat :: NonEmpty a -> a

    Reduce a non-empty list with <>

    The default definition should be sufficient, but this can be overridden for efficiency.

    Examples

    For the following examples, we will assume that we have:

    Example1 expression
    import Data.List.NonEmpty (NonEmpty (..))
    Example1 expression
    sconcat $ "Hello" :| [" ", "Haskell", "!"]"Hello Haskell!"
    Example1 expression
    sconcat $ Just [1, 2, 3] :| [Nothing, Just [4, 5, 6]]Just [1,2,3,4,5,6]
    Example1 expression
    sconcat $ Left 1 :| [Right 2, Left 3, Right 4]Right 2
  • stimes :: Integral b => b -> a -> a

    Repeat a value n times.

    The default definition will raise an exception for a multiplier that is <= 0. This may be overridden with an implementation that is total. For monoids it is preferred to use stimesMonoid.

    By making this a member of the class, idempotent semigroups and monoids can upgrade this to execute in \mathcal{O}(1) by picking stimes = stimesIdempotent or stimes = stimesIdempotentMonoid respectively.

    Examples
    Example1 expression
    stimes 4 [1][1,1,1,1]
    Example1 expression
    stimes 5 (putStr "hi!")hi!hi!hi!hi!hi!
    Example1 expression
    stimes 3 (Right ":)")Right ":)"
Instances120Semigroup, …
classclass (Functor t, Foldable t) => Traversable (t :: Type -> Type) where
#

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

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

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

Methods

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

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

    Examples

    Basic usage:

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

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

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

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

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

    Examples

    Basic usage:

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

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

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

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

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

    Examples

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

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

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

    Examples

    Basic usage:

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

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

    The following examples demonstrate short circuit behavior for sequence.

    Example1 expression
    sequence $ Left [1,2,3,4]Left [1,2,3,4]
    Example1 expression
    sequence $ [Left 0, Right 1,Right 2,Right 3,Right 4]Left 0
Instances106Traversable, …
classclass Semigroupoid (c :: k -> k -> Type) where
#

Methods

  • o :: c j k1 -> c i j -> c i k1
Instances16Semigroupoid, …
newtypenewtype Dual a
#

The dual of a Monoid, obtained by swapping the arguments of (<>).

Dual a <> Dual b == Dual (b <> a)
Examples
Example1 expression
Dual "Hello" <> Dual "World"Dual {getDual = "WorldHello"}
Example1 expression
Dual (Dual "Hello") <> Dual (Dual "World")Dual {getDual = Dual {getDual = "HelloWorld"}}

Constructors

Instances42Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
datadata Set a
#

A set of values a.

Instances20Foldable, Eq1, Ord1, Show1, Hashable1, Pointed, …
  • Foldable SetDefined in containers-0.7 · Data.Set.Internal

    Folds in order of increasing key.

  • Eq1 SetDefined in containers-0.7 · Data.Set.Internal
  • Ord1 SetDefined in containers-0.7 · Data.Set.Internal
  • Show1 SetDefined in containers-0.7 · Data.Set.Internal
  • Hashable1 SetDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Pointed SetDefined in pointed-5.0.4 · Data.Pointed
  • Lift a => Lift (Set a)Defined in containers-0.7 · Data.Set.Internal
  • Ord a => IsList (Set a)Defined in containers-0.7 · Data.Set.Internal
  • Eq a => Eq (Set a)Defined in containers-0.7 · Data.Set.Internal
  • (Data a, Ord a) => Data (Set a)Defined in containers-0.7 · Data.Set.Internal
  • Ord a => Ord (Set a)Defined in containers-0.7 · Data.Set.Internal
  • (Read a, Ord a) => Read (Set a)Defined in containers-0.7 · Data.Set.Internal
  • Show a => Show (Set a)Defined in containers-0.7 · Data.Set.Internal
  • Ord a => Semigroup (Set a)Defined in containers-0.7 · Data.Set.Internal
  • Ord a => Monoid (Set a)Defined in containers-0.7 · Data.Set.Internal
  • NFData a => NFData (Set a)Defined in containers-0.7 · Data.Set.Internal
  • Binary a => Binary (Set a)Defined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable v => Hashable (Set v)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Default (Set v)Defined in data-default-0.8.0.1 · Data.Default.Internal
  • type Item (Set a) = aDefined in containers-0.7 · Data.Set.Internal
datadata STRef s a
#

a value of type STRef s a is a mutable variable in state thread s, containing a value of type a

Example1 expression
:{runST (do    ref <- newSTRef "hello"    x <- readSTRef ref    writeSTRef ref (x ++ "world")    readSTRef ref ):}"helloworld"
Instances4NFData2, NFData1, Eq, NFData
  • NFData2 STRefDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • NFData1 (STRef s)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • Eq (STRef s a)Defined in ghc-internal-9.1003.0 · GHC.Internal.STRef

    Pointer equality.

  • NFData (STRef s a)Defined in deepseq-1.5.0.0 · Control.DeepSeq

    NOTE: Only strict in the reference and not the referenced value.

typetype String = [Char]
#

String is an alias for a list of characters.

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

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

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

Performance considerations

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

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

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

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

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

datadata Text
#

A space efficient, packed, unboxed Unicode text type.

Instances15IsList, Eq, Data, Ord, Read, Show, …
  • IsList TextDefined in text-2.1.3 · Data.Text · orphan

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedLists['\55555'] :: Text"\65533"
  • Eq TextDefined in text-2.1.3 · Data.Text · orphan
  • Data TextDefined in text-2.1.3 · Data.Text · orphan

    This instance preserves data abstraction at the cost of inefficiency. We omit reflection services for the sake of data abstraction.

    This instance was created by copying the updated behavior of Data.Set.Set and Data.Map.Data.Map.Map. If you feel a mistake has been made, please feel free to submit improvements.

    The original discussion is archived here: could we get a Data instance for Data.Text.Text?

    The followup discussion that changed the behavior of Set and Data.Map.Map is archived here: Proposal: Allow gunfold for Data.Map, ...

  • Ord TextDefined in text-2.1.3 · Data.Text · orphan
  • Read TextDefined in text-2.1.3 · Data.Text · orphan
  • Show TextDefined in text-2.1.3 · Data.Text.Show · orphan
  • IsString TextDefined in text-2.1.3 · Data.Text · orphan

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedStrings"\55555" :: Text"\65533"
  • Semigroup TextDefined in text-2.1.3 · Data.Text · orphan

    Beware: stimes will crash if the given number does not fit into an Int.

  • Monoid TextDefined in text-2.1.3 · Data.Text · orphan
  • PrintfArg TextDefined in text-2.1.3 · Data.Text · orphan
  • NFData TextDefined in text-2.1.3 · Data.Text · orphan
  • Binary TextDefined in text-2.1.3 · Data.Text · orphan
  • Hashable TextDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Lift TextDefined in text-2.1.3 · Data.Text · orphan
  • type Item Text = CharDefined in text-2.1.3 · Data.Text · orphan
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 >> and >>= operations from the Monad class.

Instances51Monad, Functor, MonadFix, MonadFail, Applicative, GHCiSandboxIO, …
classclass (RealFrac a, Floating a) => RealFloat a where
#

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

Methods

  • floatRadix :: a -> Integer

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

  • floatDigits :: a -> Int

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

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

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

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

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

  • encodeFloat :: Integer -> Int -> a

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

  • exponent :: a -> Int

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

  • significand :: a -> a

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

  • scaleFloat :: Int -> a -> a

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

  • isNaN :: a -> Bool

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

  • isInfinite :: a -> Bool

    True if the argument is an IEEE infinity or negative infinity

  • isDenormalized :: a -> Bool

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

  • isNegativeZero :: a -> Bool

    True if the argument is an IEEE negative zero

  • isIEEE :: a -> Bool

    True if the argument is an IEEE floating point number

  • atan2 :: a -> a -> a

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

Instances9RealFloat, …
classclass Read a where
#

Parsing of Strings, producing values.

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

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

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

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

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

For example, given the declarations

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

the derived instance of Read in Haskell 2010 is equivalent to

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

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

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

          where app_prec = 10
                up_prec = 5

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

The derived instance in GHC is equivalent to

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

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

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

          where app_prec = 10
                up_prec = 5

        readListPrec = readListPrecDefault

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

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

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

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

Methods

  • readsPrec :: Int -> ReadS a

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

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

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

  • readList :: ReadS [a]

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

  • readPrec :: ReadPrec a

    Proposed replacement for readsPrec using new-style parsers (GHC only).

  • readListPrec :: ReadPrec [a]

    Proposed replacement for readList using new-style parsers (GHC only). The default definition uses readList. Instances that define readPrec should also define readListPrec as readListPrecDefault.

Instances240Read, …
  • Read OptionsDefined in bifunctors-5.6.2 · Data.Bifunctor.TH
  • Read ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Read ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • Read ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • Read IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Read IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.Read

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

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

    Supports the skipping of parentheses and whitespaces. Example:

    > read " ( ((  -1.0e+3 ) ))" :: Scientific
    -1000.0

    (Note: This Read instance makes internal use of scientificP to parse the floating-point number.)

  • Read SMGenDefined in splitmix-0.1.3.1 · System.Random.SplitMix
    Example1 expression
    readMaybe "SMGen 1 1" :: Maybe SMGenJust (SMGen 1 1)
    Example1 expression
    readMaybe "SMGen 1 2" :: Maybe SMGenNothing
    Example1 expression
    readMaybe (show (mkSMGen 42)) :: Maybe SMGenJust (SMGen 9297814886316923340 13679457532755275413)
  • Read SMGenDefined in splitmix-0.1.3.1 · System.Random.SplitMix32
    Example1 expression
    readMaybe "SMGen 1 1" :: Maybe SMGenJust (SMGen 1 1)
    Example1 expression
    readMaybe "SMGen 1 2" :: Maybe SMGenNothing
    Example1 expression
    readMaybe (show (mkSMGen 42)) :: Maybe SMGenJust (SMGen 142593372 1604540297)
  • Read I8Defined in text-2.1.3 · Data.Text.Foreign
  • Read TextDefined in text-2.1.3 · Data.Text · orphan
  • Read TextDefined in text-2.1.3 · Data.Text.Lazy · orphan
  • Read FPFormatDefined in text-2.1.3 · Data.Text.Lazy.Builder.RealFloat
  • Read DatatypeVariantDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Read DayDefined in time-1.12.2 · Data.Time.Format.Parse · orphan
  • Read MonthDefined in time-1.12.2 · Data.Time.Calendar.Month

    Read as yyyy-mm.

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

    Read as yyyy-Qn.

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

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

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

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

  • Read UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Read UnpackedUUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Read ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Read a => Read (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Read a => Read (ViewL a)Defined in containers-0.7 · Data.Sequence.Internal
  • Read a => Read (ViewR a)Defined in containers-0.7 · Data.Sequence.Internal
  • Read a => Read (Tree a)Defined in containers-0.7 · Data.Tree
  • Read a => Read (DNonEmpty a)Defined in dlist-1.0 · Data.DList.DNonEmpty.Internal
  • Read a => Read (DList a)Defined in dlist-1.0 · Data.DList.Internal
  • Read a => Read (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity

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

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

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

  • Read a => Read (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read a => Read (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read a => Read (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read a => Read (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList
  • Read a => Read (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read (Array a)Defined in primitive-0.9.1.0 · Data.Primitive.Array
  • Read a => Read (SmallArray a)Defined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • Read a => Read (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Read a => Read (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Strict
  • Read a => Read (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read e => Read (IntMap e)Defined in containers-0.7 · Data.IntMap.Internal
  • Read m => Read (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Read p => Read (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read vertex => Read (SCC vertex)Defined in containers-0.7 · Data.Graph
  • (Read a, Storable a) => Read (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Storable
  • (Read a, Ord a) => Read (Set a)Defined in containers-0.7 · Data.Set.Internal
  • (Read a, Prim a) => Read (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Primitive
  • (Read a, Unbox a) => Read (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Unboxed · orphan
  • (Integral a, Read a) => Read (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Hashable a, Read a) => Read (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • HasResolution a => Read (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Read (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Read (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read (f a) => Read (Coyoneda f a)Defined in kan-extensions-5.2.7 · Data.Functor.Coyoneda
  • (Read1 f, Read a) => Read (Cofree f a)Defined in free-5.2 · Control.Comonad.Cofree
  • (Read1 f, Read a) => Read (Free f a)Defined in free-5.2 · Control.Monad.Free
  • (Read1 f, Read a) => Read (Free f a)Defined in free-5.2 · Control.Monad.Free.Ap
  • (Read1 f, Read a) => Read (Lift f a)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • (Read1 m, Read a) => Read (IterT m a)Defined in free-5.2 · Control.Monad.Trans.Iter
  • (Read1 m, Read a) => Read (MaybeT m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • (Read1 w, Read a) => Read (CoiterT w a)Defined in free-5.2 · Control.Comonad.Trans.Coiter
  • (Functor f, Read (f a)) => Read (Yoneda f a)Defined in kan-extensions-5.2.7 · Data.Functor.Yoneda
  • (Ix a, Read a, Read b) => Read (Array a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Ix ix, Read ix, Read e, IArray UArray e) => Read (UArray ix e)Defined in array-0.5.8.0 · Data.Array.Base
  • (Read a, Read b) => Read (Arg a b)Defined in base-4.20.2.0 · Data.Semigroup
  • (Read a, Read b) => Read (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either
  • (Read a, Read b) => Read (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Ord k, Read k, Read e) => Read (Map k e)Defined in containers-0.7 · Data.Map.Internal
  • (Hashable k, Read k, Read e) => Read (HashMap k e)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (GRead (Rep1 f a), Generic1 f) => Read (FunctorClassesDefault f a)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Read (bi a b) => Read (Biap bi a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biap
  • Read (f a) => Read (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Read (f a) => Read (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read (f a) => Read (WrappedContravariant f a)Defined in invariant-0.6.4 · Data.Functor.Invariant
  • Read (f a) => Read (WrappedFunctor f a)Defined in invariant-0.6.4 · Data.Functor.Invariant
  • Read (f p) => Read (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read (p (Fix p a) a) => Read (Fix p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Fix
  • Read (p a a) => Read (Join p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Join
  • Read (w (CofreeF f a (CofreeT f w a))) => Read (CofreeT f w a)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • Read a => Read (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const

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

  • Read a => Read (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • Read b => Read (Tagged s b)Defined in tagged-0.8.9 · Data.Tagged
  • Coercible a b => Read (Coercion a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • (Read1 f, Read1 m, Read a) => Read (FreeT f m a)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Read1 f, Read1 m, Read a) => Read (FreeT f m a)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Read1 f, Read a) => Read (Backwards f a)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • (Read1 f, Read a) => Read (IdentityT f a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • (Read1 f, Read a) => Read (Reverse f a)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • (Read1 f, Read e, Read a) => Read (ExceptT e f a)Defined in selective-0.7.0.1 · Control.Selective.Trans.Except
  • (Read a, Read (f b)) => Read (CofreeF f a b)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • (Read a, Read (f b)) => Read (FreeF f a b)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Read a, Read (f b)) => Read (FreeF f a b)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Read a, Read b, Read c) => Read (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read e, Read1 m, Read a) => Read (ExceptT e m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • (Read w, Read1 m, Read a) => Read (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Read w, Read1 m, Read a) => Read (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • a ~ b => Read (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Read c => Read (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read (f a), Read (g a)) => Read (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Read (f a), Read (g a)) => Read (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Read (f p), Read (g p)) => Read ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read (f p), Read (g p)) => Read ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read a, Read b, Read c, Read d) => Read (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • a ~~ b => Read (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Read (f (g a)) => Read (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Read (f (g p)) => Read ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read (f a) => Read (Clown f a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Clown
  • Read (f p) => Read (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read (g b) => Read (Joker g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Joker
  • Read (p a b) => Read (WrappedBifunctor p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Wrapped
  • Read (p a b) => Read (WrappedProfunctor p a b)Defined in invariant-0.6.4 · Data.Functor.Invariant
  • Read (p b a) => Read (Flip p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Flip
  • (Read a, Read b, Read c, Read d, Read e) => Read (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read (f a b), Read (g a b)) => Read (Product f g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Product
  • (Read (p a b), Read (q a b)) => Read (Sum p q a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Sum
  • (Read a, Read b, Read c, Read d, Read e, Read f) => Read (a, b, c, d, e, f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read (f (p a b)) => Read (Tannen f p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Tannen
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g) => Read (a, b, c, d, e, f, g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) => Read (a, b, c, d, e, f, g, h)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read (p (f a) (g b)) => Read (Biff p f g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biff
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i) => Read (a, b, c, d, e, f, g, h, i)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j) => Read (a, b, c, d, e, f, g, h, i, j)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k) => Read (a, b, c, d, e, f, g, h, i, j, k)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l) => Read (a, b, c, d, e, f, g, h, i, j, k, l)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n, Read o) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
classclass ISO8601 t where
#

Methods

Instances8ISO8601, …
  • ISO8601 CalendarDiffDaysDefined in time-1.12.2 · Data.Time.Format.ISO8601

    PyYmMdD (ISO 8601:2004(E) sec. 4.4.3.2)

  • ISO8601 DayDefined in time-1.12.2 · Data.Time.Format.ISO8601

    yyyy-mm-dd (ISO 8601:2004(E) sec. 4.1.2.2 extended format)

  • ISO8601 UTCTimeDefined in time-1.12.2 · Data.Time.Format.ISO8601

    yyyy-mm-ddThh:mm:ss[.sss]Z (ISO 8601:2004(E) sec. 4.3.2 extended format)

  • ISO8601 CalendarDiffTimeDefined in time-1.12.2 · Data.Time.Format.ISO8601

    PyYmMdDThHmMs[.sss]S (ISO 8601:2004(E) sec. 4.4.3.2)

  • ISO8601 LocalTimeDefined in time-1.12.2 · Data.Time.Format.ISO8601

    yyyy-mm-ddThh:mm:ss[.sss] (ISO 8601:2004(E) sec. 4.3.2 extended format)

  • ISO8601 TimeOfDayDefined in time-1.12.2 · Data.Time.Format.ISO8601

    hh:mm:ss[.sss] (ISO 8601:2004(E) sec. 4.2.2.2, 4.2.2.4(a) extended format)

  • ISO8601 TimeZoneDefined in time-1.12.2 · Data.Time.Format.ISO8601

    ±hh:mm (ISO 8601:2004(E) sec. 4.2.5.1 extended format)

  • ISO8601 ZonedTimeDefined in time-1.12.2 · Data.Time.Format.ISO8601

    yyyy-mm-ddThh:mm:ss[.sss]±hh:mm (ISO 8601:2004(E) sec. 4.3.2 extended format)

datadata LocalTime
#

A simple day and time aggregate, where the day is of the specified parameter, and the time is a TimeOfDay. Conversion of this (as local civil time) to UTC depends on the time zone. Conversion of this (as local mean time) to UT1 depends on the longitude.

Instances12Eq, Data, Ord, Read, Show, Generic, …
classclass Typeable (a :: k) where
#

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

newtypenewtype Unique
#

An abstract unique object. Objects of type Unique may be compared for equality and ordering and hashed into Int.

Example1 expression
:{do x <- newUnique   print (x == x)   y <- newUnique   print (x == y):}TrueFalse
Instances4Eq, Ord, NFData, Hashable
  • Eq UniqueDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Unique
  • Ord UniqueDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Unique
  • NFData UniqueDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Hashable UniqueDefined in hashable-1.4.7.0 · Data.Hashable.Class
datadata UUID
#

Type representing Universally Unique Identifiers (UUID) as specified in RFC 4122.

Instances12Eq, Data, Ord, Read, Show, Storable, …
  • Eq UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Data UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Ord UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Read UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Show UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal

    Pretty prints a UUID (without quotation marks). See also toString.

    Example1 expression
    show nil"00000000-0000-0000-0000-000000000000"
  • Storable UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal

    This Storable instance uses the memory layout as described in RFC 4122, but in contrast to the Binary instance, the fields are stored in host byte order.

  • NFData UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Random UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal

    This Random instance produces insecure version 4 UUIDs as specified in RFC 4122.

  • Uniform UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Binary UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal

    This Binary instance is compatible with RFC 4122, storing the fields in network order as 16 bytes.

  • Hashable UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Lift UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
datadata Vector a
#
Instances44Monad, Functor, MonadFix, MonadFail, Applicative, Foldable, …
  • Monad VectorDefined in vector-0.13.2.0 · Data.Vector
  • Functor VectorDefined in vector-0.13.2.0 · Data.Vector
  • MonadFix VectorDefined in vector-0.13.2.0 · Data.Vector
  • MonadFail VectorDefined in vector-0.13.2.0 · Data.Vector
  • Applicative VectorDefined in vector-0.13.2.0 · Data.Vector
  • Foldable VectorDefined in vector-0.13.2.0 · Data.Vector
  • Traversable VectorDefined in vector-0.13.2.0 · Data.Vector
  • Alternative VectorDefined in vector-0.13.2.0 · Data.Vector
  • MonadPlus VectorDefined in vector-0.13.2.0 · Data.Vector
  • MonadZip VectorDefined in vector-0.13.2.0 · Data.Vector
  • Eq1 VectorDefined in vector-0.13.2.0 · Data.Vector
  • Ord1 VectorDefined in vector-0.13.2.0 · Data.Vector
  • Read1 VectorDefined in vector-0.13.2.0 · Data.Vector
  • Show1 VectorDefined in vector-0.13.2.0 · Data.Vector
  • NFData1 VectorDefined in vector-0.13.2.0 · Data.Vector
  • Hashable1 VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Alt VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Apply VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Bind VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Extend VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Plus VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Adjustable VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • FoldableWithKey VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Indexable VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Keyed VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Lookup VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • TraversableWithKey VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Zip VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • ZipWithKey VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Pointed VectorDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • Vector Vector aDefined in vector-0.13.2.0 · Data.Vector
  • IsList (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Eq a => Eq (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Data a => Data (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Ord a => Ord (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Read a => Read (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Show a => Show (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Semigroup (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Monoid (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • NFData a => NFData (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Hashable a => Hashable (Vector a)Defined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
  • type Item (Vector a) = aDefined in vector-0.13.2.0 · Data.Vector
  • type Mutable Vector = MVectorDefined in vector-0.13.2.0 · Data.Vector
  • type Key Vector = IntDefined in vector-instances-3.4.2 · Data.Vector.Instances · orphan
classclass Generic a where
#

Representable types of kind *. This class is derivable in GHC with the DeriveGeneric flag on.

A Generic instance must satisfy the following laws:

from . to ≡ id
to . from ≡ id
Instances227Generic, …
  • Generic ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • Generic ForeignSrcLangDefined in ghc-boot-th-9.10.3 · GHC.ForeignSrcLang.Type
  • Generic ExtensionDefined in ghc-boot-th-9.10.3 · GHC.LanguageExtensions.Type
  • Generic VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic ByteOrderDefined in ghc-internal-9.1003.0 · GHC.Internal.ByteOrder
  • Generic ClosureTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.ClosureTypes
  • Generic AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Generic AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Generic VersionDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Version
  • Generic FingerprintDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic AssociativityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic DecidedStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic SourceStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic SourceUnpackednessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic ExitCodeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Generic CCFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic ConcFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic DebugFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic DoCostCentresDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic DoHeapProfileDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic DoTraceDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic GCFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic GiveGCStatsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic HpcFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic MiscFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic ParFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic ProfFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic RTSFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic TickyFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic TraceFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Generic SrcLocDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic GCDetailsDefined in ghc-internal-9.1003.0 · GHC.Internal.Stats
  • Generic RTSStatsDefined in ghc-internal-9.1003.0 · GHC.Internal.Stats
  • Generic GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic OsCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Generic OsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Generic PosixCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Generic PosixStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Generic WindowsCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Generic WindowsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Generic ModeDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Generic StyleDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Generic TextDetailsDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Generic DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJ
  • Generic AnnLookupDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic AnnTargetDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic BangDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic BndrVisDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic BodyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic BytesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic CallconvDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic ClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic ConDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic DecDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic DecidedStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic DerivClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic DerivStrategyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic DocLocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic ExpDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic FamilyResultSigDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic FixityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic FixityDirectionDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic ForeignDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic FunDepDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic GuardDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic InfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic InjectivityAnnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic InlineDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic LitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic LocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic MatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic ModNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic ModuleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic ModuleInfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic NameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic NameFlavourDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic NameSpaceDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic NamespaceSpecifierDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic OccNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic OverlapDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic PatDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic PatSynArgsDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic PatSynDirDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic PhasesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic PkgNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic PragmaDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic RangeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic RoleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic RuleBndrDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic RuleMatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic SafetyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic SourceStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic SourceUnpackednessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic SpecificityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic StmtDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic TyLitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic TySynEqnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic TypeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic TypeFamilyHeadDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic ConstructorInfoDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Generic ConstructorVariantDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Generic DatatypeInfoDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Generic DatatypeVariantDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Generic FieldStrictnessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Generic StrictnessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Generic UnpackednessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Generic CalendarDiffDaysDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • Generic DayDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • Generic QuarterDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • Generic UTCTimeDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • Generic UniversalTimeDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • Generic CalendarDiffTimeDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • Generic LocalTimeDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • Generic TimeOfDayDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • Generic TimeZoneDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • Generic ZonedTimeDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • Generic ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Generic (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Generic (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Generic (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Generic (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Generic (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Generic (SCC vertex)Defined in containers-0.7 · Data.Graph
  • Generic (Digit a)Defined in containers-0.7 · Data.Sequence.Internal
  • Generic (Elem a)Defined in containers-0.7 · Data.Sequence.Internal
  • Generic (FingerTree a)Defined in containers-0.7 · Data.Sequence.Internal
  • Generic (Node a)Defined in containers-0.7 · Data.Sequence.Internal
  • Generic (ViewL a)Defined in containers-0.7 · Data.Sequence.Internal
  • Generic (ViewR a)Defined in containers-0.7 · Data.Sequence.Internal
  • Generic (Tree a)Defined in containers-0.7 · Data.Tree
  • Generic (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Generic (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Generic (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Generic (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Generic (Endo a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Generic (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Generic (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Generic (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList
  • Generic (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Generic (TyVarBndr flag)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Generic (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (WrappedMonad m a)Defined in base-4.20.2.0 · Control.Applicative
  • Generic (Arg a b)Defined in base-4.20.2.0 · Data.Semigroup
  • Generic (Cofree f a)Defined in free-5.2 · Control.Comonad.Cofree
  • Generic (Free f a)Defined in free-5.2 · Control.Monad.Free
  • Generic (Free f a)Defined in free-5.2 · Control.Monad.Free.Ap
  • Generic (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (Lift f a)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • Generic (MaybeT m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • Generic (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (WrappedArrow a b c)Defined in base-4.20.2.0 · Control.Applicative
  • Generic (Biap bi a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biap
  • Generic (Fix p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Fix
  • Generic (Join p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Join
  • Generic (CofreeF f a b)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • Generic (FreeF f a b)Defined in free-5.2 · Control.Monad.Trans.Free
  • Generic (FreeF f a b)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • Generic (Kleisli m a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Arrow
  • Generic (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Generic (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Generic (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Generic (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (URec Char 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
  • Generic (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (URec Int p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (URec Word p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (URec (Ptr ()) p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (Tagged s b)Defined in tagged-0.8.9 · Data.Tagged
  • Generic (Backwards f a)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • Generic (AccumT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Accum
  • Generic (ExceptT e m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • Generic (IdentityT f a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • Generic (ReaderT r m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Reader
  • Generic (SelectT r m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Select
  • Generic (StateT s m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Lazy
  • Generic (StateT s m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Strict
  • Generic (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.CPS
  • Generic (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • Generic (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • Generic (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • Generic (Reverse f a)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • Generic (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • Generic (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.Sum
  • Generic (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (ContT r m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Cont
  • Generic ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Generic (Clown f a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Clown
  • Generic (Flip p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Flip
  • Generic (Joker g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Joker
  • Generic (WrappedBifunctor p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Wrapped
  • Generic (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (RWST r w s m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.CPS
  • Generic (RWST r w s m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.Lazy
  • Generic (RWST r w s m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.Strict
  • Generic ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (Product f g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Product
  • Generic (Sum p q a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Sum
  • Generic (a, b, c, d, e, f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (Tannen f p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Tannen
  • Generic (a, b, c, d, e, f, g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (Biff p f g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biff
  • Generic (a, b, c, d, e, f, g, h, i)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h, i, j)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h, i, j, k)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h, i, j, k, l)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h, i, j, k, l, m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
classclass Storable a where
#

The member functions of this class facilitate writing values of primitive types to raw memory (which may have been allocated with the above mentioned routines) and reading values from blocks of raw memory. The class, furthermore, includes support for computing the storage requirements and alignment restrictions of storable types.

Memory addresses are represented as values of type Ptr a, for some a which is an instance of class Storable. The type argument to Ptr helps provide some valuable type safety in FFI code (you can't mix pointers of different types without an explicit cast), while helping the Haskell type system figure out which marshalling method is needed for a given pointer.

All marshalling between Haskell and a foreign language ultimately boils down to translating Haskell data structures into the binary representation of a corresponding data structure of the foreign language and vice versa. To code this marshalling in Haskell, it is necessary to manipulate primitive data types stored in unstructured memory blocks. The class Storable facilitates this manipulation on all types for which it is instantiated, which are the standard basic types of Haskell, the fixed size Int types (Int8, Int16, Int32, Int64), the fixed size Word types (Word8, Word16, Word32, Word64), StablePtr, all types from Foreign.C.Types, as well as Ptr.

Methods

  • sizeOf :: a -> Int

    Computes the storage requirements (in bytes) of the argument. The value of the argument is not used.

  • alignment :: a -> Int

    Computes the alignment constraint of the argument. An alignment constraint x is fulfilled by any address divisible by x. The alignment must be a power of two if this instance is to be used with alloca or allocaArray. The value of the argument is not used.

  • peekElemOff :: Ptr a -> Int -> IO a

    Read a value from a memory area regarded as an array of values of the same kind. The first argument specifies the start address of the array and the second the index into the array (the first element of the array has index 0). The following equality holds,

    peekElemOff addr idx = IOExts.fixIO $ \result ->
      peek (addr `plusPtr` (idx * sizeOf result))

    Note that this is only a specification, not necessarily the concrete implementation of the function.

  • pokeElemOff :: Ptr a -> Int -> a -> IO ()

    Write a value to a memory area regarded as an array of values of the same kind. The following equality holds:

    pokeElemOff addr idx x =
      poke (addr `plusPtr` (idx * sizeOf x)) x
  • peekByteOff :: Ptr b -> Int -> IO a

    Read a value from a memory location given by a base address and offset. The following equality holds:

    peekByteOff addr off = peek (addr `plusPtr` off)
  • pokeByteOff :: Ptr b -> Int -> a -> IO ()

    Write a value to a memory location given by a base address and offset. The following equality holds:

    pokeByteOff addr off x = poke (addr `plusPtr` off) x
  • peek :: Ptr a -> IO a

    Read a value from the given memory location.

    Note that the peek and poke functions might require properly aligned addresses to function correctly. This is architecture dependent; thus, portable code should ensure that when peeking or poking values of some type a, the alignment constraint for a, as given by the function alignment is fulfilled.

  • poke :: Ptr a -> a -> IO ()

    Write the given value to the given memory location. Alignment restrictions might apply; see peek.

Instances92Storable, …
  • Storable EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.EPoll
  • Storable EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Poll
  • Storable PollFdDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Poll
  • Storable FingerprintDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Storable IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Storable WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Storable FLockDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Lock.LinuxOFD
  • Storable Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable IoSubSystemDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Storable CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CTimerDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Storable Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable CharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable CTimespecDefined in time-1.12.2 · Data.Time.Clock.Internal.CTimespec
  • Storable CTimevalDefined in time-1.12.2 · Data.Time.Clock.Internal.CTimeval
  • Storable UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal

    This Storable instance uses the memory layout as described in RFC 4122, but in contrast to the Binary instance, the fields are stored in host byte order.

  • Storable ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable (ConstPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable (FunPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable (Ptr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable (StablePtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable a => Storable (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Storable a => Storable (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Storable a => Storable (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Storable g => Storable (StateGen g)Defined in random-1.2.1.3 · System.Random.Internal
  • Storable g => Storable (AtomicGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Storable g => Storable (IOGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Storable g => Storable (STGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Storable g => Storable (TGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Prim a => Storable (PrimStorable a)Defined in primitive-0.9.1.0 · Data.Primitive.Types
  • (Storable a, Integral a) => Storable (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • Storable a => Storable (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Storable a => Storable (Tagged s a)Defined in tagged-0.8.9 · Data.Tagged
datadata Version
#

A Version represents the version of a software entity.

An instance of Eq is provided, which implements exact equality modulo reordering of the tags in the versionTags field.

An instance of Ord is also provided, which gives lexicographic ordering on the versionBranch fields (i.e. 2.1 > 2.0, 1.2.3 > 1.2.2, etc.). This is expected to be sufficient for many uses, but note that you may need to use a more specific ordering for your versioning scheme. For example, some versioning schemes may include pre-releases which have tags "pre1", "pre2", and so on, and these would need to be taken into account when determining ordering. In some cases, date ordering may be more appropriate, so the application would have to look for date tags in the versionTags field and compare those. The bottom line is, don't always assume that compare and other Ord operations are the right thing for every Version.

Similarly, concrete representations of versions may differ. One possible concrete representation is provided (see showVersion and parseVersion), but depending on the application a different concrete representation may be more appropriate.

Constructors

  • Version
    • versionBranch :: [Int]

      The numeric branch for this version. This reflects the fact that most software versions are tree-structured; there is a main trunk which is tagged with versions at various points (1,2,3...), and the first branch off the trunk after version 3 is 3.1, the second branch off the trunk after version 3 is 3.2, and so on. The tree can be branched arbitrarily, just by adding more digits.

      We represent the branch as a list of Int, so version 3.2.1 becomes [3,2,1]. Lexicographic ordering (i.e. the default instance of Ord for [Int]) gives the natural ordering of branches.

    • versionTags :: [String]

      A version can be tagged with an arbitrary list of strings. The interpretation of the list of tags is entirely dependent on the entity that this version applies to.

Instances12IsList, Eq, Data, Ord, Read, Show, …
datadata Void
#

Uninhabited data type

Instances33Eq, Data, Ord, Read, Show, Ix, …
datadata Word
#

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

Instances44Bounded, Enum, Integral, Data, Num, Read, …
datadata ForeignPtr a
#

The type ForeignPtr represents references to objects that are maintained in a foreign language, i.e., that are not part of the data structures usually managed by the Haskell storage manager. The essential difference between ForeignPtrs and vanilla memory references of type Ptr a is that the former may be associated with finalizers. A finalizer is a routine that is invoked when the Haskell storage manager detects that - within the Haskell heap and stack - there are no more references left that are pointing to the ForeignPtr. Typically, the finalizer will, then, invoke routines in the foreign language that free the resources bound by the foreign object.

The ForeignPtr is parameterised in the same way as Ptr. The type argument of ForeignPtr should normally be an instance of class Storable.

Instances7Eq, Data, Ord, Show, HasGetter, HasSetter, …
datadata Ptr a
#

A value of type Ptr a represents a pointer to an object, or an array of objects, which may be marshalled to or from Haskell values of type a.

The type a will often be an instance of class Storable which provides the marshalling operations. However this is not essential, and you can provide your own operations to access the pointer. For example you might write small foreign functions to get or set the fields of a C struct.

Instances26NFData1, IArray, Generic1, Data, Show, Foldable, …
datadata StablePtr a
#

A stable pointer is a reference to a Haskell expression that is guaranteed not to be affected by garbage collection, i.e., it will neither be deallocated nor will the value of the stable pointer itself change during garbage collection (ordinary references may be relocated during garbage collection). Consequently, stable pointers can be passed to foreign code, which can treat it as an opaque reference to a Haskell value.

The StablePtr 0 is reserved for representing NULL in foreign code.

A value of type StablePtr a is a stable pointer to a Haskell expression of type a.

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

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

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

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

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

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

    Example1 expression
    [0..1.5 :: Float][0.0,1.0,2.0]
  • Enum IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum LevityDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum VecCountDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum VecElemDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum InvariantClassDefined in invariant-0.6.4 · Data.Functor.Invariant.TH.Internal
  • Enum CardinalityDefined in random-1.2.1.3 · System.Random.GFinite

    This is needed only as a superclass of Integral.

  • Enum I8Defined in text-2.1.3 · Data.Text.Foreign
  • Enum FPFormatDefined in text-2.1.3 · Data.Text.Lazy.Builder.RealFloat
  • Enum DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • Enum MonthDefined in time-1.12.2 · Data.Time.Calendar.Month
  • Enum QuarterDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Enum QuarterOfYearDefined in time-1.12.2 · Data.Time.Calendar.Quarter

    maps Q1..Q4 to 1..4

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

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

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

    Swaps succ and pred of the underlying type.

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

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

    Example1 expression
    succ (0.000 :: Milli)0.001

    and likewise

    Example1 expression
    pred (0.000 :: Milli)-0.001

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

    Example1 expression
    succ (0.000000000000 :: Pico)0.000000000001

    and similarly

    Example1 expression
    pred (0.000000000000 :: Pico)-0.000000000001

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

      [1..10] :: [Pico]
    

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

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

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

    and contains 9 * 10^12 + 1 values.

  • Enum (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Enum (bi a b) => Enum (Biap bi a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biap
  • 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
  • Enum a => Enum (Tagged s a)Defined in tagged-0.8.9 · Data.Tagged
  • 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
datadata Environment (p :: Type -> Type -> Type) a b where
#

Constructors

Instances8ProfunctorMonad, ProfunctorAdjunction, ProfunctorFunctor, Closed, Profunctor, Invariant2, …
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, Fractional, Data, Num, Read, …
  • Enum FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

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

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

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

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

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

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

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

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

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

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

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

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

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

    Beware that toRational generates garbage for non-finite arguments:

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

    Beware that results for non-finite arguments are garbage:

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

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

  • Show FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan
  • Storable FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • PrintfArg FloatDefined in base-4.20.2.0 · Text.Printf
  • NFData FloatDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Pretty FloatDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Pretty FloatDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Random FloatDefined in random-1.2.1.3 · System.Random

    Note - random produces values in the closed range [0,1].

  • UniformRange FloatDefined in random-1.2.1.3 · System.Random.Internal
  • Binary FloatDefined in binary-0.8.9.3 · Data.Binary.Class

    Uses non-IEEE754 encoding. Does not round-trip NaN.

  • Hashable FloatDefined in hashable-1.4.7.0 · Data.Hashable.Class

    Note: prior to hashable-1.3.0.0, hash 0.0 /= hash (-0.0)

    The hash of NaN is not well defined.

  • Prim FloatDefined in primitive-0.9.1.0 · Data.Primitive.Types
  • Unbox FloatDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Default FloatDefined in data-default-0.8.0.1 · Data.Default.Internal
  • Lift FloatDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • IArray UArray FloatDefined in array-0.5.8.0 · Data.Array.Base
  • Vector Vector FloatDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector FloatDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MArray IOUArray Float IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • Generic1 (URec Float)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Foldable UFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Foldable
  • Traversable UFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Traversable
  • MArray (STUArray s) Float (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • Functor (URec Float)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • type Rep (URec Float p) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UFloat" 'PrefixI 'True) (S1 ('MetaSel ('Just "uFloat#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UFloat))Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • type Rep1 (URec Float) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UFloat" 'PrefixI 'True) (S1 ('MetaSel ('Just "uFloat#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UFloat))Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • data URec FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics

    Used for marking occurrences of Float#

  • data MVector s FloatDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector FloatDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
datadata Handle
#

Haskell defines operations to read and write characters from and to files, represented by values of type Handle. Each value of this type is a handle: a record used by the Haskell run-time system to manage I/O with file system objects. A handle has at least the following properties:

  • whether it manages input or output or both;

  • whether it is open, closed or semi-closed;

  • whether the object is seekable;

  • whether buffering is disabled, or enabled on a line or block basis;

  • a buffer (whose length may be zero).

Most handles will also have a current I/O position indicating where the next input or output operation will occur. A handle is readable if it manages only input or both input and output; likewise, it is writable if it manages only output or both input and output. A handle is open when first allocated. Once it is closed it can no longer be used for either input or output, though an implementation cannot re-use its storage while references remain to it. Handles are in the Show and Eq classes. The string produced by showing a handle is system dependent; it should include enough information to identify the handle for debugging. A handle is equal according to == only to itself; no attempt is made to compare the internal state of different handles for equality.

Instances2Eq, Show
  • Eq HandleDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Show HandleDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
classclass Num a where
#

Basic numeric class.

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

Associativity of (+)

(x + y) + z

=

x + (y + z)

Commutativity of (+)

x + y

=

y + x

fromInteger 0 is the additive identity

x + fromInteger 0

=

x

negate gives the additive inverse

x + negate x

=

fromInteger 0

Associativity of (*)

(x * y) * z

=

x * (y * z)

fromInteger 1 is the multiplicative identity

x * fromInteger 1

=

x

and

fromInteger 1 * x

=

x

Distributivity of (*) with respect to (+)

a * (b + c)

=

(a * b) + (a * c)

and

(b + c) * a

=

(b * a) + (c * a)

Coherence with toInteger

if the type also implements

GHC.Real.Integral

, then

fromInteger

is a left inverse for

toInteger

, i.e.

fromInteger (toInteger i) == i

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

Methods

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

    Unary negation.

  • abs :: a -> a

    Absolute value.

  • signum :: a -> a

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

    abs x * signum x == x

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

  • fromInteger :: Integer -> a

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

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

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

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

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

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

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

    Example3 expressions
    (0.1 + 0.1 :: Float) + 0.5 == 0.1 + (0.1 + 0.5)False(0.1 + 0.2 :: Float) * 0.9 == 0.1 * 0.9 + 0.2 * 0.9False(0.1 * 0.1 :: Float) * 0.9 == 0.1 * (0.1 * 0.9)False
  • Num IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Num
  • Num WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Num
  • Num CardinalityDefined in random-1.2.1.3 · System.Random.GFinite
  • Num ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    WARNING: + and - compute the Integer magnitude: 10^e where e is the difference between the base10Exponents of the arguments. If these methods are applied to arguments which have huge exponents this could fill up all space and crash your program! So don't apply these methods to scientific numbers coming from untrusted sources. The other methods can be used safely.

  • Num I8Defined in text-2.1.3 · Data.Text.Foreign
  • Num SizeDefined in text-2.1.3 · Data.Text.Internal.Fusion.Size
  • Num DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Num NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Num SizeDefined in vector-0.13.2.0 · Data.Vector.Fusion.Bundle.Size
  • RealFloat a => Num (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Num a => Num (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Num a => Num (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Num a => Num (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Num a => Num (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Num a => Num (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Num a => Num (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Integral a => Num (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • HasResolution a => Num (Fixed a)Defined in base-4.20.2.0 · Data.Fixed

    Multiplication is not associative or distributive:

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

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

    Commutativity:

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

    Additive inverse:

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

    Distributivity:

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

Real numbers.

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

Coherence with fromRational

if the type also implements

Fractional

, then

fromRational

is a left inverse for

toRational

, i.e.

fromRational (toRational i) = i

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

Methods

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

    Beware that toRational generates garbage for non-finite arguments:

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

    Beware that toRational generates garbage for non-finite arguments:

    Example2 expressions
    toRational (1/0 :: Float)340282366920938463463374607431768211456 % 1toRational (0/0 :: Float)510423550381407695195061911147652317184 % 1
  • Real IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real CardinalityDefined in random-1.2.1.3 · System.Random.GFinite

    This is needed only as a superclass of Integral.

  • Real ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    WARNING: toRational needs to compute the Integer magnitude: 10^e. If applied to a huge exponent this could fill up all space and crash your program!

    Avoid applying toRational (or realToFrac) to scientific numbers coming from an untrusted source and use toRealFloat instead. The latter guards against excessive space usage.

  • Real I8Defined in text-2.1.3 · Data.Text.Foreign
  • Real DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Real NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Integral a => Real (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real a => Real (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Real a => Real (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • HasResolution a => Real (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Real a => Real (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Real a => Real (Tagged s a)Defined in tagged-0.8.9 · Data.Tagged
  • Real (f (g a)) => Real (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
classclass Show a where
#

Conversion of values to readable Strings.

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

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

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

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

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

For example, given the declarations

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

the derived instance of Show is equivalent to

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

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

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

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

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

Methods

  • showsPrec :: Int -> a -> ShowS

    Convert a value to a readable String.

    showsPrec should satisfy the law

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

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

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

  • show :: a -> String

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

  • showList :: [a] -> ShowS

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

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

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

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

    Prints the raw bytes without decoding.

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

    Decodes as UCS-2.

  • Show ModeDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show StyleDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show TextDetailsDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Show DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJ
  • Show PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Show CardinalityDefined in random-1.2.1.3 · System.Random.GFinite
  • Show StdGenDefined in random-1.2.1.3 · System.Random.Internal
  • Show ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    See formatScientific if you need more control over the rendering.

  • Show SMGenDefined in splitmix-0.1.3.1 · System.Random.SplitMix
  • Show SMGenDefined in splitmix-0.1.3.1 · System.Random.SplitMix32
  • Show ForallVisFlagDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Ppr
  • Show DocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.PprLib
  • Show AnnLookupDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show AnnTargetDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show BangDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show BndrVisDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show BodyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show BytesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show CallconvDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ConDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DecDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DecidedStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DerivClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DerivStrategyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DocLocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ExpDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show FamilyResultSigDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show FixityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show FixityDirectionDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ForeignDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show FunDepDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show GuardDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show InfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show InjectivityAnnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show InlineDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show LitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show LocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show MatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ModNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ModuleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ModuleInfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show NameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show NameFlavourDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show NameSpaceDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show NamespaceSpecifierDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show OccNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show OverlapDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PatDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PatSynArgsDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PatSynDirDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PhasesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PkgNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PragmaDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show RangeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show RoleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show RuleBndrDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show RuleMatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show SafetyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show SourceStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show SourceUnpackednessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show SpecificityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show StmtDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show TyLitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show TySynEqnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show TypeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show TypeFamilyHeadDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DecodingDefined in text-2.1.3 · Data.Text.Encoding
  • Show UnicodeExceptionDefined in text-2.1.3 · Data.Text.Encoding.Error
  • Show I8Defined in text-2.1.3 · Data.Text.Foreign
  • Show TextDefined in text-2.1.3 · Data.Text.Show · orphan
  • Show BuilderDefined in text-2.1.3 · Data.Text.Internal.Builder
  • Show PartialUtf8CodePointDefined in text-2.1.3 · Data.Text.Internal.Encoding
  • Show Utf8StateDefined in text-2.1.3 · Data.Text.Internal.Encoding
  • Show DecoderStateDefined in text-2.1.3 · Data.Text.Internal.Encoding.Utf8
  • Show SizeDefined in text-2.1.3 · Data.Text.Internal.Fusion.Size
  • Show TextDefined in text-2.1.3 · Data.Text.Lazy · orphan
  • Show FPFormatDefined in text-2.1.3 · Data.Text.Lazy.Builder.RealFloat
  • Show IterDefined in text-2.1.3 · Data.Text.Unsafe
  • Show ConstructorInfoDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Show ConstructorVariantDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Show DatatypeInfoDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Show DatatypeVariantDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Show FieldStrictnessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Show StrictnessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Show UnpackednessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Show CalendarDiffDaysDefined in time-1.12.2 · Data.Time.Calendar.CalendarDiffDays
  • Show DayDefined in time-1.12.2 · Data.Time.Calendar.Gregorian · orphan
  • Show MonthDefined in time-1.12.2 · Data.Time.Calendar.Month

    Show as yyyy-mm.

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

    Show as yyyy-Qn.

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

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

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

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

  • Show SubHashPathDefined in unordered-containers-0.2.21 · Data.HashMap.Internal.Debug
  • Show UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal

    Pretty prints a UUID (without quotation marks). See also toString.

    Example1 expression
    show nil"00000000-0000-0000-0000-000000000000"
  • Show UnpackedUUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
  • Show SizeDefined in vector-0.13.2.0 · Data.Vector.Fusion.Bundle.Size
  • Show ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show (ConstPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.ConstPtr
  • Show (ForeignPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ForeignPtr
  • Show (FunPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Show (Ptr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Show (SChar c)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Show (SSymbol s)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Show (SNat n)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • Show (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show a => Show (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Show a => Show (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Show a => Show (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Show a => Show (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Show a => Show (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Show a => Show (Decoder a)Defined in binary-0.8.9.3 · Data.Binary.Get.Internal
  • Show a => Show (IntMap a)Defined in containers-0.7 · Data.IntMap.Internal
  • Show a => Show (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Show a => Show (ViewL a)Defined in containers-0.7 · Data.Sequence.Internal
  • Show a => Show (ViewR a)Defined in containers-0.7 · Data.Sequence.Internal
  • Show a => Show (Intersection a)Defined in containers-0.7 · Data.Set.Internal
  • Show a => Show (Set a)Defined in containers-0.7 · Data.Set.Internal
  • Show a => Show (Tree a)Defined in containers-0.7 · Data.Tree
  • Show a => Show (DNonEmpty a)Defined in dlist-1.0 · Data.DList.DNonEmpty.Internal
  • Show a => Show (DList a)Defined in dlist-1.0 · Data.DList.Internal
  • Show a => Show (ExitCase a)Defined in exceptions-0.10.9 · Control.Monad.Catch
  • Show a => Show (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show a => Show (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity

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

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

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

  • Show a => Show (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show a => Show (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show a => Show (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show a => Show (ExceptionWithContext a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Type
  • Show a => Show (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList
  • Show a => Show (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show a => Show (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Show a => Show (Hashed a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Show a => Show (AnnotDetails a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show a => Show (Span a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show a => Show (Array a)Defined in primitive-0.9.1.0 · Data.Primitive.Array
  • Show a => Show (SmallArray a)Defined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • Show a => Show (Array a)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal.Array
  • Show a => Show (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Show a => Show (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Show a => Show (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Strict
  • Show a => Show (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show a => Show [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show e => Show (NoBacktrace e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Type
  • Show flag => Show (TyVarBndr flag)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show g => Show (StateGen g)Defined in random-1.2.1.3 · System.Random.Internal
  • Show g => Show (AtomicGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Show g => Show (IOGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Show g => Show (STGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Show g => Show (TGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Show k => Show (Error k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal.Debug
  • Show k => Show (Validity k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal.Debug
  • 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
  • Show vertex => Show (SCC vertex)Defined in containers-0.7 · Data.Graph
  • (Show a, Storable a) => Show (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Storable
  • (Show a, Prim a) => Show (PrimArray a)Defined in primitive-0.9.1.0 · Data.Primitive.PrimArray
  • (Show a, Prim a) => Show (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Primitive
  • (Show a, Unbox a) => Show (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Unboxed · orphan
  • 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 (UAddr p)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • 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 (f a) => Show (Yoneda f a)Defined in kan-extensions-5.2.7 · Data.Functor.Yoneda
  • Show m => Show (Over m a)Defined in selective-0.7.0.1 · Control.Selective
  • Show m => Show (Under m a)Defined in selective-0.7.0.1 · Control.Selective
  • Show m => Show (Over m a)Defined in selective-0.7.0.1 · Control.Selective.Multi
  • Show m => Show (Under m a)Defined in selective-0.7.0.1 · Control.Selective.Multi
  • (Show1 f, Show a) => Show (Cofree f a)Defined in free-5.2 · Control.Comonad.Cofree
  • (Show1 f, Show a) => Show (Free f a)Defined in free-5.2 · Control.Monad.Free
  • (Show1 f, Show a) => Show (Free f a)Defined in free-5.2 · Control.Monad.Free.Ap
  • (Show1 f, Show a) => Show (Lift f a)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • (Show1 m, Show a) => Show (IterT m a)Defined in free-5.2 · Control.Monad.Trans.Iter
  • (Show1 m, Show a) => Show (MaybeT m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • (Show1 w, Show a) => Show (CoiterT w a)Defined in free-5.2 · Control.Comonad.Trans.Coiter
  • (Functor f, Show1 f, Show a) => Show (Coyoneda f a)Defined in kan-extensions-5.2.7 · Data.Functor.Coyoneda
  • (Ix a, Show a, Show b) => Show (Array a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Arr
  • (Ix ix, Show ix, Show e, IArray UArray e) => Show (UArray ix e)Defined in array-0.5.8.0 · Data.Array.Base
  • (Show a, Show b) => Show (Arg a b)Defined in base-4.20.2.0 · Data.Semigroup
  • (Show a, Show b) => Show (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either
  • (Show a, Show b) => Show (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show e, Show a) => Show (Validation e a)Defined in either-5.0.3 · Data.Either.Validation
  • (Show e, Show a) => Show (Validation e a)Defined in selective-0.7.0.1 · Control.Selective
  • (Show k, Show a) => Show (Map k a)Defined in containers-0.7 · Data.Map.Internal
  • (Show k, Show v) => Show (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (GShow (Rep1 f a), Generic1 f) => Show (FunctorClassesDefault f a)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • 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 (bi a b) => Show (Biap bi a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biap
  • 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 a) => Show (WrappedContravariant f a)Defined in invariant-0.6.4 · Data.Functor.Invariant
  • Show (f a) => Show (WrappedFunctor f a)Defined in invariant-0.6.4 · Data.Functor.Invariant
  • Show (f p) => Show (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (p (Fix p a) a) => Show (Fix p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Fix
  • Show (p a a) => Show (Join p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Join
  • Show (w (CofreeF f a (CofreeT f w a))) => Show (CofreeT f w a)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • Show a => Show (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const

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

  • Show a => Show (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • Show b => Show (Tagged s b)Defined in tagged-0.8.9 · Data.Tagged
  • (Show1 f, Show1 m, Show a) => Show (FreeT f m a)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Show1 f, Show1 m, Show a) => Show (FreeT f m a)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Show1 f, Show a) => Show (Backwards f a)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • (Show1 f, Show a) => Show (IdentityT f a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • (Show1 f, Show a) => Show (Reverse f a)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • (Show1 f, Show e, Show a) => Show (ExceptT e f a)Defined in selective-0.7.0.1 · Control.Selective.Trans.Except
  • (Show a, Show (f b)) => Show (CofreeF f a b)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • (Show a, Show (f b)) => Show (FreeF f a b)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Show a, Show (f b)) => Show (FreeF f a b)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Show a, Show b, Show c) => Show (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show e, Show1 m, Show a) => Show (ExceptT e m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • (Show w, Show1 m, Show a) => Show (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Show w, Show1 m, Show a) => Show (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • Show (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Show c => Show (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Show (f a), Show (g a)) => Show (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Show (f a), Show (g a)) => Show (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Show (f p), Show (g p)) => Show ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Show (f p), Show (g p)) => Show ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Show a, Show b, Show c, Show d) => Show (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show (f (g a)) => Show (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Show (f (g p)) => Show ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (f a) => Show (Clown f a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Clown
  • Show (f p) => Show (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (g b) => Show (Joker g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Joker
  • Show (p a b) => Show (WrappedBifunctor p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Wrapped
  • Show (p a b) => Show (WrappedProfunctor p a b)Defined in invariant-0.6.4 · Data.Functor.Invariant
  • Show (p b a) => Show (Flip p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Flip
  • (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 (f a b), Show (g a b)) => Show (Product f g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Product
  • (Show (p a b), Show (q a b)) => Show (Sum p q a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Sum
  • (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 (f (p a b)) => Show (Tannen f p a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Tannen
  • (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 (p (f a) (g b)) => Show (Biff p f g a b)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biff
  • (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
datadata Natural
#

Natural number

Invariant: numbers <= 0xffffffffffffffff use the NS constructor

Instances20Enum, Eq, Integral, Data, Num, Ord, …
  • Enum NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Eq NaturalDefined in ghc-bignum-1.3 · GHC.Num.Natural
  • Integral NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Data NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Num

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

  • Ord NaturalDefined in ghc-bignum-1.3 · GHC.Num.Natural
  • Read NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Real NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Show NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Ix NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Bits NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Bits
  • PrintfArg NaturalDefined in base-4.20.2.0 · Text.Printf
  • NFData NaturalDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • UniformRange NaturalDefined in random-1.2.1.3 · System.Random.Internal
  • Binary NaturalDefined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable NaturalDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Lift NaturalDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • TestCoercion SNatDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • TestEquality SNatDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • type Compare a b = CmpNat a bDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Ord
datadata StableName a
#

An abstract name for an object, that supports equality and hashing.

Stable names have the following property:

  • If sn1 :: StableName and sn2 :: StableName and sn1 == sn2 then sn1 and sn2 were created by calls to makeStableName on the same object.

The reverse is not necessarily true: if two stable names are not equal, then the objects they name may still be equal. Note in particular that makeStableName may return a different StableName after an object is evaluated.

Stable Names are similar to Stable Pointers (Foreign.StablePtr), but differ in the following ways:

  • There is no freeStableName operation, unlike Foreign.StablePtrs. Stable names are reclaimed by the runtime system when they are no longer needed.

  • There is no deRefStableName operation. You can't get back from a stable name to the original Haskell object. The reason for this is that the existence of a stable name for an object does not guarantee the existence of the object itself; it can still be garbage collected.

Instances4NFData1, Eq, NFData, Hashable
newtypenewtype Timeout
#

An exception thrown to a thread by timeout to interrupt a timed-out computation.

Instances3Eq, Show, Exception
newtypenewtype ReadPrec a
#
Instances7Monad, Functor, MonadFail, Applicative, Alternative, MonadPlus, …
  • Monad ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrec
  • Functor ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrec
  • MonadFail ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrec
  • Applicative ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrec
  • Alternative ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrec
  • MonadPlus ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrec
  • Invariant ReadPrecDefined in invariant-0.6.4 · Data.Functor.Invariant
valuemapLeft :: Bifunctor p => (a -> b) -> p a c -> p b c
#

A more meaningful and conflict-free alias for first.

valueoptional :: Alternative f => f a -> f (Maybe a)
#

One or none.

It is useful for modelling any computation that is allowed to fail.

Examples

Using the Alternative instance of Control.Monad.Except, the following functions:

Example1 expression
import Control.Monad.Except
Example2 expressions
canFail = throwError "it failed" :: Except String Intfinal = return 42                :: Except String Int

Can be combined by allowing the first function to fail:

Example1 expression
runExcept $ canFail *> finalLeft "it failed"
Example1 expression
runExcept $ optional canFail *> finalRight 42
valueforkFinally :: IO a -> (Either SomeException a -> IO ()) -> IO ThreadId
#

Fork a thread and call the supplied function when the thread is about to terminate, with an exception or a returned value. The function is called with asynchronous exceptions masked.

forkFinally action and_then =
  mask $ \restore ->
    forkIO $ try (restore action) >>= and_then

This function is useful for informing the parent when a child terminates, for example.

valuethreadWaitRead :: Fd -> IO ()
#

Block the current thread until data is available to read on the given file descriptor (GHC only).

This will throw an IOError if the file descriptor was closed while this thread was blocked. To safely close a file descriptor that has been used with threadWaitRead, use closeFdWith.

valuethreadWaitReadSTM :: Fd -> IO (STM (), IO ())
#

Returns an STM action that can be used to wait for data to read from a file descriptor. The second returned value is an IO action that can be used to deregister interest in the file descriptor.

valuethreadWaitWrite :: Fd -> IO ()
#

Block the current thread until data can be written to the given file descriptor (GHC only).

This will throw an IOError if the file descriptor was closed while this thread was blocked. To safely close a file descriptor that has been used with threadWaitWrite, use closeFdWith.

valuethreadWaitWriteSTM :: Fd -> IO (STM (), IO ())
#

Returns an STM action that can be used to wait until data can be written to a file descriptor. The second returned value is an IO action that can be used to deregister interest in the file descriptor.

valuedupChan :: Chan a -> IO (Chan a)
#

Duplicate a Chan: the duplicate channel begins empty, but data written to either channel from then on will be available from both. Hence this creates a kind of broadcast channel, where data written by anyone is seen by everyone else.

(Note that a duplicated channel is not equal to its original. So: fmap (c /=) $ dupChan c returns True for all c.)

valuegetChanContents :: Chan a -> IO [a]
#

Return a lazy list representing the contents of the supplied Chan, much like GHC.Internal.System.IO.hGetContents.

valuereadChan :: Chan a -> IO a
#

Read the next value from the Chan. Blocks when the channel is empty. Since the read end of a channel is an MVar, this operation inherits fairness guarantees of MVars (e.g. threads blocked in this operation are woken up in FIFO order).

Throws BlockedIndefinitelyOnMVar when the channel is empty and no other thread holds a reference to the channel.

valuenewQSem :: Int -> IO QSem
#

Build a new QSem with a supplied initial quantity. The initial quantity must be at least 0.

valuenewQSemN :: Int -> IO QSemN
#

Build a new QSemN with a supplied initial quantity. The initial quantity must be at least 0.

valuedigitToInt :: Char -> Int
#

Convert a single digit Char to the corresponding Int. This function fails unless its argument satisfies isHexDigit, but recognises both upper- and lower-case hexadecimal digits (that is, '0'..'9', 'a'..'f', 'A'..'F').

Examples

Characters '0' through '9' are converted properly to 0..9:

Example1 expression
map digitToInt ['0'..'9'][0,1,2,3,4,5,6,7,8,9]

Both upper- and lower-case 'A' through 'F' are converted as well, to 10..15.

Example2 expressions
map digitToInt ['a'..'f'][10,11,12,13,14,15]map digitToInt ['A'..'F'][10,11,12,13,14,15]

Anything else throws an exception:

Example2 expressions
digitToInt 'G'*** Exception: Char.digitToInt: not a digit 'G'digitToInt '♥'*** Exception: Char.digitToInt: not a digit '\9829'
valueisLetter :: Char -> Bool
#

Selects alphabetic Unicode characters (lower-case, upper-case and title-case letters, plus letters of caseless scripts and modifiers letters). This function is equivalent to isAlpha.

This function returns True if its argument has one of the following GeneralCategorys, or False otherwise:

These classes are defined in the Unicode Character Database, part of the Unicode standard. The same document defines what is and is not a "Letter".

Examples

Basic usage:

Example7 expressions
isLetter 'a'TrueisLetter 'A'TrueisLetter 'λ'TrueisLetter '0'FalseisLetter '%'FalseisLetter '♥'FalseisLetter '\31'False

Ensure that isLetter and isAlpha are equivalent.

Example4 expressions
let chars = [(chr 0)..]let letters = map isLetter charslet alphas = map isAlpha charsletters == alphasTrue
valueisMark :: Char -> Bool
#

Selects Unicode mark characters, for example accents and the like, which combine with preceding characters.

This function returns True if its argument has one of the following GeneralCategorys, or False otherwise:

These classes are defined in the Unicode Character Database, part of the Unicode standard. The same document defines what is and is not a "Mark".

Examples

Basic usage:

Example2 expressions
isMark 'a'FalseisMark '0'False

Combining marks such as accent characters usually need to follow another character before they become printable:

Example1 expression
map isMark "ò"[False,True]

Puns are not necessarily supported:

Example1 expression
isMark '✓'False
valueisNumber :: Char -> Bool
#

Selects Unicode numeric characters, including digits from various scripts, Roman numerals, et cetera.

This function returns True if its argument has one of the following GeneralCategorys, or False otherwise:

These classes are defined in the Unicode Character Database, part of the Unicode standard. The same document defines what is and is not a "Number".

Examples

Basic usage:

Example3 expressions
isNumber 'a'FalseisNumber '%'FalseisNumber '3'True

ASCII '0' through '9' are all numbers:

Example1 expression
and $ map isNumber ['0'..'9']True

Unicode Roman numerals are "numbers" as well:

Example1 expression
isNumber 'Ⅸ'True
valueisSeparator :: Char -> Bool
#

Selects Unicode space and separator characters.

This function returns True if its argument has one of the following GeneralCategorys, or False otherwise:

These classes are defined in the Unicode Character Database, part of the Unicode standard. The same document defines what is and is not a "Separator".

Examples

Basic usage:

Example3 expressions
isSeparator 'a'FalseisSeparator '6'FalseisSeparator ' 'True

Warning: newlines and tab characters are not considered separators.

Example2 expressions
isSeparator '\n'FalseisSeparator '\t'False

But some more exotic characters are (like HTML's &nbsp;):

Example1 expression
isSeparator '\160'True
valuecis :: Floating a => a -> Complex a
#

cis t is a complex value with magnitude 1 and phase t (modulo 2*pi).

cis = mkPolar 1
Examples
Example1 expression
cis 01.0 :+ 0.0

The following examples are not perfectly zero due to IEEE 754

Example1 expression
cis pi(-1.0) :+ 1.2246467991473532e-16
Example1 expression
cis (4 * pi) - cis (2 * pi)0.0 :+ (-2.4492935982947064e-16)
valueconjugate :: Num a => Complex a -> Complex a
#

The conjugate of a complex number.

Property
conjugate (conjugate x) = x
Examples
Example1 expression
conjugate (3.0 :+ 3.0)3.0 :+ (-3.0)
Example1 expression
conjugate ((3.0 :+ 3.0) * (2.0 :+ 2.0))0.0 :+ (-12.0)
valueimagPart :: Complex a -> a
#

Extracts the imaginary part of a complex number.

Examples
Example1 expression
imagPart (5.0 :+ 3.0)3.0
Example1 expression
imagPart ((5.0 :+ 3.0) * (2.0 :+ 3.0))21.0
valuemagnitude :: RealFloat a => Complex a -> a
#

The non-negative magnitude of a complex number.

Examples
Example1 expression
magnitude (1.0 :+ 1.0)1.4142135623730951
Example1 expression
magnitude (1.0 + 0.0)1.0
Example1 expression
magnitude (0.0 :+ (-5.0))5.0
valuemkPolar :: Floating a => a -> a -> Complex a
#

Form a complex number from polar components of magnitude and phase.

Examples
Example1 expression
mkPolar 1 (pi / 4)0.7071067811865476 :+ 0.7071067811865475
Example1 expression
mkPolar 1 01.0 :+ 0.0
valuephase :: RealFloat a => Complex a -> a
#

The phase of a complex number, in the range (-pi, pi]. If the magnitude is zero, then so is the phase.

Examples
Example1 expression
phase (0.5 :+ 0.5) / pi0.25
Example1 expression
phase (0 :+ 4) / pi0.5
valuepolar :: RealFloat a => Complex a -> (a, a)
#

The function polar takes a complex number and returns a (magnitude, phase) pair in canonical form: the magnitude is non-negative, and the phase in the range (-pi, pi]; if the magnitude is zero, then so is the phase.

polar z = (magnitude z, phase z)
Examples
Example1 expression
polar (1.0 :+ 1.0)(1.4142135623730951,0.7853981633974483)
Example1 expression
polar ((-1.0) :+ 0.0)(1.0,3.141592653589793)
Example1 expression
polar (0.0 :+ 0.0)(0.0,0.0)
valuerealPart :: Complex a -> a
#

Extracts the real part of a complex number.

Examples
Example1 expression
realPart (5.0 :+ 3.0)5.0
Example1 expression
realPart ((5.0 :+ 3.0) * (2.0 :+ 3.0))1.0
valuemod' :: Real a => a -> a -> a
#

Generalisation of mod to any instance of Real

valueshowFixed :: HasResolution a => Bool -> Fixed a -> String
#

First arg is whether to chop off trailing zeros

Examples
Example1 expression
showFixed True  (MkFixed 10000 :: Fixed E3)"10"
Example1 expression
showFixed False (MkFixed 10000 :: Fixed E3)"10.000"
valuefoldlM1 :: (Foldable1 t, Monad m) => (a -> a -> m a) -> t a -> m a
#

Monadic fold over the elements of a non-empty structure, associating to the left, i.e. from left to right.

valuefoldrM1 :: (Foldable1 t, Monad m) => (a -> a -> m a) -> t a -> m a
#

Monadic fold over the elements of a non-empty structure, associating to the right, i.e. from right to left.

valueintercalate1 :: (Foldable1 t, Semigroup m) => m -> t m -> m
#

Insert an m between each pair of t m.

Example1 expression
intercalate1 ", " $ "hello" :| ["how", "are", "you"]"hello, how, are, you"
Example1 expression
intercalate1 ", " $ "hello" :| []"hello"
Example1 expression
intercalate1 mempty $ "I" :| ["Am", "Fine", "You?"]"IAmFineYou?"
valueeq1 :: (Eq1 f, Eq a) => f a -> f a -> Bool
#

Lift the standard (==) function through the type constructor.

valueeq2 :: (Eq2 f, Eq a, Eq b) => f a b -> f a b -> Bool
#

Lift the standard (==) function through the type constructor.

value($<) :: Contravariant f => f b -> b -> f a
#

This is >$ with its arguments flipped.

valuephantom :: (Functor f, Contravariant f) => f a -> f b
#

If f is both Functor and Contravariant then by the time you factor in the laws of each of those classes, it can't actually use its argument in any meaningful capacity.

This method is surprisingly useful. Where both instances exist and are lawful we have the following laws:

fmap      f ≡ phantom
contramap f ≡ phantom
valuecycle1 :: Semigroup m => m -> m
#

A generalization of cycle to an arbitrary Semigroup. May fail to terminate for some values in some semigroups.

Examples
Example1 expression
take 10 $ cycle1 [1, 2, 3][1,2,3,1,2,3,1,2,3,1]
Example1 expression
cycle1 (Right 1)Right 1
Example1 expression
cycle1 (Left 1)* hangs forever *
valuediff :: Semigroup m => m -> Endo m
#

This lets you use a difference list of a Semigroup as a Monoid.

Examples
let hello = diff "Hello, "
Example1 expression
appEndo hello "World!""Hello, World!"
Example1 expression
appEndo (hello <> mempty) "World!""Hello, World!"
Example1 expression
appEndo (mempty <> hello) "World!""Hello, World!"
let world = diff "World"
let excl = diff "!"
Example1 expression
appEndo (hello <> (world <> excl)) mempty"Hello, World!"
Example1 expression
appEndo ((hello <> world) <> excl) mempty"Hello, World!"
valuemtimesDefault :: (Integral b, Monoid a) => b -> a -> a
#

Repeat a value n times.

mtimesDefault n a = a <> a <> ... <> a  -- using <> (n-1) times

In many cases, stimes 0 a for a Monoid will produce mempty. However, there are situations when it cannot do so. In particular, the following situation is fairly common:

data T a = ...

class Constraint1 a
class Constraint1 a => Constraint2 a
instance Constraint1 a => Semigroup (T a)
instance Constraint2 a => Monoid (T a)

Since Constraint1 is insufficient to implement mempty, stimes for T a cannot do so.

When working with such a type, or when working polymorphically with Semigroup instances, mtimesDefault should be used when the multiplier might be zero. It is implemented using stimes when the multiplier is nonzero and mempty when it is zero.

Examples
Example1 expression
mtimesDefault 0 "bark"[]
Example1 expression
mtimesDefault 3 "meow""meowmeowmeow"
valueunsafeFixIO :: (a -> IO a) -> IO a
#

A slightly faster version of fixIO that may not be safe to use with multiple threads. The unsafety arises when used like this:

 unsafeFixIO $ \r -> do
    forkIO (print r)
    return (...)

In this case, the child thread will receive a NonTermination exception instead of waiting for the value of r to be computed.

valuetimeout :: Int -> IO a -> IO (Maybe a)
#

Wrap an IO computation to time out and return Nothing in case no result is available within n microseconds (1/10^6 seconds). In case a result is available before the timeout expires, Just a is returned. A negative timeout interval means "wait indefinitely". When specifying long timeouts, be careful not to exceed maxBound :: Int, which on 32-bit machines is only 2147483647 μs, less than 36 minutes. Consider using Control.Concurrent.Timeout.timeout from unbounded-delays package.

Example1 expression
timeout 1000000 (threadDelay 1000 *> pure "finished on time")Just "finished on time"
Example1 expression
timeout 10000 (threadDelay 100000 *> pure "finished on time")Nothing

The design of this combinator was guided by the objective that timeout n f should behave exactly the same as f as long as f doesn't time out. This means that f has the same myThreadId it would have without the timeout wrapper. Any exceptions f might throw cancel the timeout and propagate further up. It also possible for f to receive exceptions thrown to it by another thread.

A tricky implementation detail is the question of how to abort an IO computation. This combinator relies on asynchronous exceptions internally (namely throwing the computation the Timeout exception). The technique works very well for computations executing inside of the Haskell runtime system, but it doesn't work at all for non-Haskell code. Foreign function calls, for example, cannot be timed out with this combinator simply because an arbitrary C function cannot receive asynchronous exceptions. When timeout is used to wrap an FFI call that blocks, no timeout event can be delivered until the FFI call returns, which pretty much negates the purpose of the combinator. In practice, however, this limitation is less severe than it may sound. Standard I/O functions like GHC.Internal.System.IO.hGetBuf, GHC.Internal.System.IO.hPutBuf, Network.Socket.accept, or GHC.Internal.System.IO.hWaitForInput appear to be blocking, but they really don't because the runtime system uses scheduling mechanisms like select(2) to perform asynchronous I/O, so it is possible to interrupt standard socket I/O or file I/O using this combinator.

valueprintf :: PrintfType r => String -> r
#

Format a variable number of arguments with the C-style formatting string.

Example1 expression
printf "%s, %d, %.4f" "hello" 123 pihello, 123, 3.1416

The return value is either String or (IO a) (which should be (IO ()), but Haskell's type system makes this hard).

The format string consists of ordinary characters and conversion specifications, which specify how to format one of the arguments to printf in the output string. A format specification is introduced by the % character; this character can be self-escaped into the format string using %%. A format specification ends with a format character that provides the primary information about how to format the value. The rest of the conversion specification is optional. In order, one may have flag characters, a width specifier, a precision specifier, and type-specific modifier characters.

Unlike C printf(3), the formatting of this printf is driven by the argument type; formatting is type specific. The types formatted by printf "out of the box" are:

printf is also extensible to support other types: see below.

A conversion specification begins with the character %, followed by zero or more of the following flags:

-      left adjust (default is right adjust)
+      always use a sign (+ or -) for signed conversions
space  leading space for positive numbers in signed conversions
0      pad with zeros rather than spaces
#      use an \"alternate form\": see below

When both flags are given, - overrides 0 and + overrides space. A negative width specifier in a * conversion is treated as positive but implies the left adjust flag.

The "alternate form" for unsigned radix conversions is as in C printf(3):

%o           prefix with a leading 0 if needed
%x           prefix with a leading 0x if nonzero
%X           prefix with a leading 0X if nonzero
%b           prefix with a leading 0b if nonzero
%[eEfFgG]    ensure that the number contains a decimal point

Any flags are followed optionally by a field width:

num    field width
*      as num, but taken from argument list

The field width is a minimum, not a maximum: it will be expanded as needed to avoid mutilating a value.

Any field width is followed optionally by a precision:

.num   precision
.      same as .0
.*     as num, but taken from argument list

Negative precision is taken as 0. The meaning of the precision depends on the conversion type.

Integral    minimum number of digits to show
RealFloat   number of digits after the decimal point
String      maximum number of characters

The precision for Integral types is accomplished by zero-padding. If both precision and zero-pad are given for an Integral field, the zero-pad is ignored.

Any precision is followed optionally for Integral types by a width modifier; the only use of this modifier being to set the implicit size of the operand for conversion of a negative operand to unsigned:

hh     Int8
h      Int16
l      Int32
ll     Int64
L      Int64

The specification ends with a format character:

c      character               Integral
d      decimal                 Integral
o      octal                   Integral
x      hexadecimal             Integral
X      hexadecimal             Integral
b      binary                  Integral
u      unsigned decimal        Integral
f      floating point          RealFloat
F      floating point          RealFloat
g      general format float    RealFloat
G      general format float    RealFloat
e      exponent format float   RealFloat
E      exponent format float   RealFloat
s      string                  String
v      default format          any type

The "%v" specifier is provided for all built-in types, and should be provided for user-defined type formatters as well. It picks a "best" representation for the given type. For the built-in types the "%v" specifier is converted as follows:

c      Char
u      other unsigned Integral
d      other signed Integral
g      RealFloat
s      String

Mismatch between the argument types and the format string, as well as any other syntactic or semantic errors in the format string, will cause an exception to be thrown at runtime.

Note that the formatting for RealFloat types is currently a bit different from that of C printf(3), conforming instead to showEFloat, showFFloat and showGFloat (and their alternate versions showFFloatAlt and showGFloatAlt). This is hard to fix: the fixed versions would format in a backward-incompatible way. In any case the Haskell behavior is generally more sensible than the C behavior. A brief summary of some key differences:

  • Haskell printf never uses the default "6-digit" precision used by C printf.

  • Haskell printf treats the "precision" specifier as indicating the number of digits after the decimal point.

  • Haskell printf prints the exponent of e-format numbers without a gratuitous plus sign, and with the minimum possible number of digits.

  • Haskell printf will place a zero after a decimal point when possible.

value(<<$>>) :: (a -> b) -> a -> b
#
value(<@@>) :: ComonadApply w => w a -> w (a -> b) -> w b
#

A variant of <@> with the arguments reversed.

value(=<=) :: Comonad w => (w b -> c) -> (w a -> b) -> w a -> c
#

Right-to-left Cokleisli composition

value(=>=) :: Comonad w => (w a -> b) -> (w b -> c) -> w a -> c
#

Left-to-right Cokleisli composition

valuecfix :: Comonad w => (w a -> a) -> w a
#

Comonadic fixed point à la Dominic Orchard

valueliftW3 :: ComonadApply w => (a -> b -> c -> d) -> w a -> w b -> w c -> w d
#

Lift a ternary function into a Comonad with zipping

valuewfix :: Comonad w => w (w a -> a) -> a
#

Comonadic fixed point à la David Menendez

value($!!) :: NFData a => (a -> b) -> a -> b
#

the deep analogue of $!. In the expression f $!! x, x is fully evaluated before the function f is applied to it.

valueforce :: NFData a => a -> a
#

a variant of deepseq that is useful in some circumstances:

force x = x `deepseq` x

force x fully evaluates x, and then returns it. Note that force x only performs evaluation when the value of force x itself is demanded, so essentially it turns shallow evaluation into deep evaluation.

force can be conveniently used in combination with ViewPatterns:

{-# LANGUAGE BangPatterns, ViewPatterns #-}
import Control.DeepSeq

someFun :: ComplexData -> SomeResult
someFun (force -> !arg) = {- 'arg' will be fully evaluated -}

Another useful application is to combine force with evaluate in order to force deep evaluation relative to other IO operations:

import Control.Exception (evaluate)
import Control.DeepSeq

main = do
  result <- evaluate $ force $ pureComputation
  {- 'result' will be fully evaluated at this point -}
  return ()

Finally, here's an exception safe variant of the readFile' example:

readFile' :: FilePath -> IO String
readFile' fn = bracket (openFile fn ReadMode) hClose $ \h ->
                       evaluate . force =<< hGetContents h
valuernf1 :: (NFData1 f, NFData a) => f a -> ()
#

Lift the standard rnf function through the type constructor.

valuerwhnf :: a -> ()
#

Reduce to weak head normal form

Equivalent to \x -> seq x ().

Useful for defining NFData for types for which NF=WHNF holds.

data T = C1 | C2 | C3
instance NFData T where rnf = rwhnf
valueeitherToError :: MonadError e m => Either e a -> m a
#

Generalize Either e as MonadError e m.

If the argument has form Left e, an error is produced in the monad via throwError. Otherwise, the Right a part is forwarded.

valuefromLeft' :: Either a b -> a
#

Extracts the element out of a Left and throws an error if its argument take the form Right _.

Using Control.Lens:

fromLeft' x ≡ x^?!_Left
Example1 expression
fromLeft' (Left 12)12
valuefromRight' :: Either a b -> b
#

Extracts the element out of a Right and throws an error if its argument take the form Left _.

Using Control.Lens:

fromRight' x ≡ x^?!_Right
Example1 expression
fromRight' (Right 12)12
valuemapBoth :: (a -> c) -> (b -> d) -> Either a b -> Either c d
#

The mapBoth function takes two functions and applies the first if iff the value takes the form Left _ and the second if the value takes the form Right _.

Using Data.Bifunctor:

mapBoth = bimap

Using Control.Arrow:

mapBoth = (+++)
Example1 expression
mapBoth (*2) (*3) (Left 4)Left 8
Example1 expression
mapBoth (*2) (*3) (Right 4)Right 12
valuemaybeToLeft :: b -> Maybe a -> Either a b
#

Maybe produce a Left, otherwise produce a Right.

Example1 expression
maybeToLeft "default" (Just 12)Left 12
Example1 expression
maybeToLeft "default" NothingRight "default"
valuemaybeToRight :: b -> Maybe a -> Either b a
#

Maybe produce a Right, otherwise produce a Left.

Example1 expression
maybeToRight "default" (Just 12)Right 12
Example1 expression
maybeToRight "default" NothingLeft "default"
valueswapEither :: Either e a -> Either a e
#

Swap the Left and Right sides of an Either.

Example1 expression
swapEither (Right 3)Left 3
Example1 expression
swapEither (Left "error")Right "error"
valuewhenLeft :: Applicative m => Either a b -> (a -> m ()) -> m ()
#

The whenLeft function takes an Either value and a function which returns a monad. The monad is only executed when the given argument takes the form Left _, otherwise it does nothing.

Using Control.Lens:

whenLeft ≡ forOf_ _Left
Example1 expression
whenLeft (Left 12) print12
valuewhenRight :: Applicative m => Either a b -> (b -> m ()) -> m ()
#

The whenRight function takes an Either value and a function which returns a monad. The monad is only executed when the given argument takes the form Right _, otherwise it does nothing.

Using Data.Foldable:

whenRight ≡ forM_

Using Control.Lens:

whenRight ≡ forOf_ _Right
Example1 expression
whenRight (Right 12) print12
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(<**>) :: Applicative f => f a -> f (a -> b) -> f b
#

A variant of <*> with the types of the arguments reversed. It differs from flip (<*>) in that the effects are resolved in the order the arguments are presented.

Examples
Example1 expression
(<**>) (print 1) (id <$ print 2)12
Example1 expression
flip (<*>) (print 1) (id <$ print 2)21
Example1 expression
ZipList [4, 5, 6] <**> ZipList [(+1), (*2), (/3)]ZipList {getZipList = [5.0,10.0,2.0]}
value(=<<) :: Monad m => (a -> m b) -> m a -> m b
#

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

as >>= f == f =<< as
valueabsurd :: Void -> a
#

Since Void values logically don't exist, this witnesses the logical reasoning tool of "ex falso quodlibet".

Example2 expressions
let x :: Either Void Int; x = Right 5:{case x of    Right r -> r    Left l  -> absurd l:}5
valueap :: Monad m => m (a -> b) -> m a -> m b
#

In many situations, the liftM operations can be replaced by uses of ap, which promotes function application.

return f `ap` x1 `ap` ... `ap` xn

is equivalent to

liftM<n> f x1 x2 ... xn
Examples
Example1 expression
pure (\x y z -> x + y * z) `ap` Just 1 `ap` Just 5 `ap` Just 10Just 51
valueasTypeOf :: a -> a -> a
#

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

valueconst :: a -> b -> a
#

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

const x = \_ -> x

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

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

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

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

Lift a function to actions. Equivalent to Functor's fmap but implemented using only Applicative's methods: liftA f a = pure f <*> a

As such this function may be used to implement a Functor instance from an Applicative one.

Examples

Using the Applicative instance for Lists:

Example1 expression
liftA (+1) [1, 2][2,3]

Or the Applicative instance for Maybe

Example1 expression
liftA (+1) (Just 3)Just 4
valueliftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
#

Lift a ternary function to actions.

valueliftM :: Monad m => (a1 -> r) -> m a1 -> m r
#

Promote a function to a monad. This is equivalent to fmap but specialised to Monads.

valueliftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
#

Promote a function to a monad, scanning the monadic arguments from left to right.

Examples
Example1 expression
liftM2 (+) [0,1] [0,2][0,2,1,3]
Example1 expression
liftM2 (+) (Just 1) NothingNothing
Example1 expression
liftM2 (+) (+ 3) (* 2) 518
valueliftM3 :: Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
#

Promote a function to a monad, scanning the monadic arguments from left to right (cf. liftM2).

valueliftM4
  1. :: Monad m
  2. => a1 -> a2 -> a3 -> a4 -> r
  3. -> m a1
  4. -> m a2
  5. -> m a3
  6. -> m a4
  7. -> m r
#

Promote a function to a monad, scanning the monadic arguments from left to right (cf. liftM2).

valueliftM5
  1. :: Monad m
  2. => a1 -> a2 -> a3 -> a4 -> a5 -> r
  3. -> m a1
  4. -> m a2
  5. -> m a3
  6. -> m a4
  7. -> m a5
  8. -> m r
#

Promote a function to a monad, scanning the monadic arguments from left to right (cf. liftM2).

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

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

valuevacuous :: Functor f => f Void -> f a
#

If Void is uninhabited then any Functor that holds only values of type Void is holding no values. It is implemented in terms of fmap absurd.

valuewhen :: Applicative f => Bool -> f () -> f ()
#

Conditional execution of Applicative expressions. For example,

Examples
when debug (putStrLn "Debugging")

will output the string Debugging if the Boolean value debug is True, and otherwise do nothing.

Example1 expression
putStr "pi:" >> when False (print 3.14159)pi:
valuepopCountDefault :: (Bits a, Num a) => a -> Int
#

Default implementation for popCount.

This implementation is intentionally naive. Instances are expected to provide an optimized implementation for their size.

valuetoIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b
#

Attempt to convert an Integral type a to an Integral type b using the size of the types as measured by Bits methods.

A simpler version of this function is:

toIntegral :: (Integral a, Integral b) => a -> Maybe b
toIntegral x
  | toInteger x == toInteger y = Just y
  | otherwise                  = Nothing
  where
    y = fromIntegral x

This version requires going through Integer, which can be inefficient. However, toIntegralSized is optimized to allow GHC to statically determine the relative type sizes (as measured by bitSizeMaybe and isSigned) and avoid going through Integer for many types. (The implementation uses fromIntegral, which is itself optimized with rules for base types but may go through Integer for some type pairs.)

valueforkOS :: IO () -> IO ThreadId
#

Like forkIO, this sparks off a new thread to run the IO computation passed as the first argument, and returns the ThreadId of the newly created thread.

However, forkOS creates a bound thread, which is necessary if you need to call foreign (non-Haskell) libraries that make use of thread-local state, such as OpenGL (see Control.Concurrent#boundthreads).

Using forkOS instead of forkIO makes no difference at all to the scheduling behaviour of the Haskell runtime system. It is a common misconception that you need to use forkOS instead of forkIO to avoid blocking all the Haskell threads when making a foreign call; this isn't the case. To allow foreign calls to be made without blocking all the Haskell threads (with GHC), it is only necessary to use the -threaded option when linking your program, and to make sure the foreign import is not marked unsafe.

Returns True if the calling thread is bound, that is, if it is safe to use foreign libraries that rely on thread-local state from the calling thread.

valuerunInBoundThread :: IO a -> IO a
#

Run the IO computation passed as the first argument. If the calling thread is not bound, a bound thread is created temporarily. runInBoundThread doesn't finish until the IO computation finishes.

You can wrap a series of foreign function calls that rely on thread-local state with runInBoundThread so that you can use them without knowing whether the current thread is bound.

valuerunInUnboundThread :: IO a -> IO a
#

Run the IO computation passed as the first argument. If the calling thread is bound, an unbound thread is created temporarily using forkIO. runInBoundThread doesn't finish until the IO computation finishes.

Use this function only in the rare case that you have actually observed a performance loss due to the use of bound threads. A program that doesn't need its main thread to be bound and makes heavy use of concurrency (e.g. a web server), might want to wrap its main action in runInUnboundThread.

Note that exceptions which are thrown to the current thread are thrown in turn to the thread that is executing the given computation. This ensures there's always a way of killing the forked thread.

valuecloseFdWith
  1. :: (Fd -> IO ())

    Low-level action that performs the real close.

  2. -> Fd

    File descriptor to close.

  3. -> IO ()
#

Close a file descriptor in a concurrency-safe way (GHC only). If you are using threadWaitRead or threadWaitWrite to perform blocking I/O, you must use this function to close file descriptors, or blocked threads may not be woken.

Any threads that are blocked on the file descriptor via threadWaitRead or threadWaitWrite will be unblocked by having IO exceptions thrown.

valueregisterDelay :: Int -> IO (TVar Bool)
#

Switch the value of returned TVar from initial value False to True after a given number of microseconds. The caveats associated with threadDelay also apply.

Be careful not to exceed maxBound :: Int, which on 32-bit machines is only 2147483647 μs, less than 36 minutes.

valuethreadDelay :: Int -> IO ()
#

Suspends the current thread for a given number of microseconds (GHC only).

There is no guarantee that the thread will be rescheduled promptly when the delay has expired, but the thread will never continue to run earlier than specified.

Be careful not to exceed maxBound :: Int, which on 32-bit machines is only 2147483647 μs, less than 36 minutes. Consider using Control.Concurrent.Thread.Delay.delay from unbounded-delays package.

valueatomically :: STM a -> IO a
#

Perform a series of STM actions atomically.

Using atomically inside an unsafePerformIO or unsafeInterleaveIO subverts some of guarantees that STM provides. It makes it possible to run a transaction inside of another transaction, depending on when the thunk is evaluated. If a nested transaction is attempted, an exception is thrown by the runtime. It is possible to safely use atomically inside unsafePerformIO or unsafeInterleaveIO, but the typechecker does not rule out programs that may attempt nested transactions, meaning that the programmer must take special care to prevent these.

However, there are functions for creating transactional variables that can always be safely called in unsafePerformIO. See: newTVarIO, newTChanIO, newBroadcastTChanIO, newTQueueIO, newTBQueueIO, and newTMVarIO.

Using unsafePerformIO inside of atomically is also dangerous but for different reasons. See unsafeIOToSTM for more on this.

valuecatchSTM :: Exception e => STM a -> (e -> STM a) -> STM a
#

Exception handling within STM actions.

catchSTM m f catches any exception thrown by m using throwSTM, using the function f to handle the exception. If an exception is thrown, any changes made by m are rolled back, but changes prior to m persist.

valueenableAllocationLimit :: IO ()
#

Enables the allocation counter to be treated as a limit for the current thread. When the allocation limit is enabled, if the allocation counter counts down below zero, the thread will be sent the AllocationLimitExceeded asynchronous exception. When this happens, the counter is reinitialised (by default to 100K, but tunable with the +RTS -xq option) so that it can handle the exception and perform any necessary clean up. If it exhausts this additional allowance, another AllocationLimitExceeded exception is sent, and so forth. Like other asynchronous exceptions, the AllocationLimitExceeded exception is deferred while the thread is inside mask or an exception handler in catch.

Note that memory allocation is unrelated to live memory, also known as heap residency. A thread can allocate a large amount of memory and retain anything between none and all of it. It is better to think of the allocation limit as a limit on CPU time, rather than a limit on memory.

Compared to using timeouts, allocation limits don't count time spent blocked or in foreign calls.

valueforkIO :: IO () -> IO ThreadId
#

Creates a new thread to run the IO computation passed as the first argument, and returns the ThreadId of the newly created thread.

The new thread will be a lightweight, unbound thread. Foreign calls made by this thread are not guaranteed to be made by any particular OS thread; if you need foreign calls to be made by a particular OS thread, then use forkOS instead.

The new thread inherits the masked state of the parent (see GHC.Control.Exception.mask).

The newly created thread has an exception handler that discards the exceptions BlockedIndefinitelyOnMVar, BlockedIndefinitelyOnSTM, and ThreadKilled, and passes all other exceptions to the uncaught exception handler.

WARNING: Exceptions in the new thread will not be rethrown in the thread that created it. This means that you might be completely unaware of the problem if/when this happens. You may want to use the async library instead.

valueforkIOWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId
#

Like forkIO, but the child thread is passed a function that can be used to unmask asynchronous exceptions. This function is typically used in the following way

 ... mask_ $ forkIOWithUnmask $ \unmask ->
                catch (unmask ...) handler

so that the exception handler in the child thread is established with asynchronous exceptions masked, meanwhile the main body of the child thread is executed in the unmasked state.

Note that the unmask function passed to the child thread should only be used in that thread; the behaviour is undefined if it is invoked in a different thread.

valueforkOn :: Int -> IO () -> IO ThreadId
#

Like forkIO, but lets you specify on which capability the thread should run. Unlike a forkIO thread, a thread created by forkOn will stay on the same capability for its entire lifetime (forkIO threads can migrate between capabilities according to the scheduling policy). forkOn is useful for overriding the scheduling policy when you know in advance how best to distribute the threads.

The Int argument specifies a capability number (see getNumCapabilities). Typically capabilities correspond to physical processors, but the exact behaviour is implementation-dependent. The value passed to forkOn is interpreted modulo the total number of capabilities as returned by getNumCapabilities.

GHC note: the number of capabilities is specified by the +RTS -N option when the program is started. Capabilities can be fixed to actual processor cores with +RTS -qa if the underlying operating system supports that, although in practice this is usually unnecessary (and may actually degrade performance in some cases - experimentation is recommended).

valuelabelThread :: ThreadId -> String -> IO ()
#

labelThread stores a string as identifier for this thread. This identifier will be used in the debugging output to make distinction of different threads easier (otherwise you only have the thread state object's address in the heap). It also emits an event to the RTS eventlog.

Make a weak pointer to a ThreadId. It can be important to do this if you want to hold a reference to a ThreadId while still allowing the thread to receive the BlockedIndefinitely family of exceptions (e.g. BlockedIndefinitelyOnMVar). Holding a normal ThreadId reference will prevent the delivery of BlockedIndefinitely exceptions because the reference could be used as the target of throwTo at any time, which would unblock the thread.

Holding a Weak ThreadId, on the other hand, will not prevent the thread from receiving BlockedIndefinitely exceptions. It is still possible to throw an exception to a Weak ThreadId, but the caller must use deRefWeak first to determine whether the thread still exists.

valuenumCapabilities :: Int
#

the value passed to the +RTS -N flag. This is the number of Haskell threads that can run truly simultaneously at any given time, and is typically set to the number of physical processor cores on the machine.

Strictly speaking it is better to use getNumCapabilities, because the number of capabilities might vary at runtime.

valuenumSparks :: IO Int
#

Returns the number of sparks currently in the local spark pool

valuepar :: a -> b -> b
#
valuepseq :: a -> b -> b
#
valuereadTVarIO :: TVar a -> IO a
#

Return the current value stored in a TVar. This is equivalent to

 readTVarIO = atomically . readTVar

but works much faster, because it doesn't perform a complete transaction, it just reads the current value of the TVar.

valueretry :: STM a
#

Retry execution of the current memory transaction because it has seen values in TVars which mean that it should not continue (e.g. the TVars represent a shared buffer that is now empty). The implementation may block the thread until one of the TVars that it has read from has been updated. (GHC only)

valuerunSparks :: IO ()
#

Internal function used by the RTS to run sparks.

valuesetAllocationCounter :: Int64 -> IO ()
#

Every thread has an allocation counter that tracks how much memory has been allocated by the thread. The counter is initialized to zero, and setAllocationCounter sets the current value. The allocation counter counts *down*, so in the absence of a call to setAllocationCounter its value is the negation of the number of bytes of memory allocated by the thread.

There are two things that you can do with this counter:

Allocation accounting is accurate only to about 4Kbytes.

valuesetNumCapabilities :: Int -> IO ()
#

Set the number of Haskell threads that can run truly simultaneously (on separate physical processors) at any given time. The number passed to forkOn is interpreted modulo this value. The initial value is given by the +RTS -N runtime flag.

This is also the number of threads that will participate in parallel garbage collection. It is strongly recommended that the number of capabilities is not set larger than the number of physical processor cores, and it may often be beneficial to leave one or more cores free to avoid contention with other processes in the machine.

valuethreadCapability :: ThreadId -> IO (Int, Bool)
#

Returns the number of the capability on which the thread is currently running, and a boolean indicating whether the thread is locked to that capability or not. A thread is locked to a capability if it was created with forkOn.

valuethrowSTM :: Exception e => e -> STM a
#

A variant of throw that can only be used within the STM monad.

Throwing an exception in STM aborts the transaction and propagates the exception. If the exception is caught via catchSTM, only the changes enclosed by the catch are rolled back; changes made outside of catchSTM persist.

If the exception is not caught inside of the STM, it is re-thrown by atomically, and the entire STM is rolled back.

Although throwSTM has a type that is an instance of the type of throw, the two functions are subtly different:

throw e    `seq` x  ===> throw e
throwSTM e `seq` x  ===> x

The first example will cause the exception e to be raised, whereas the second one won't. In fact, throwSTM will only cause an exception to be raised when it is used within the STM monad. The throwSTM variant should be used in preference to throw to raise an exception within the STM monad because it guarantees ordering with respect to other STM operations, whereas throw does not.

valuethrowTo :: Exception e => ThreadId -> e -> IO ()
#

throwTo raises an arbitrary exception in the target thread (GHC only).

Exception delivery synchronizes between the source and target thread: throwTo does not return until the exception has been raised in the target thread. The calling thread can thus be certain that the target thread has received the exception. Exception delivery is also atomic with respect to other exceptions. Atomicity is a useful property to have when dealing with race conditions: e.g. if there are two threads that can kill each other, it is guaranteed that only one of the threads will get to kill the other.

Whatever work the target thread was doing when the exception was raised is not lost: the computation is suspended until required by another thread.

If the target thread is currently making a foreign call, then the exception will not be raised (and hence throwTo will not return) until the call has completed. This is the case regardless of whether the call is inside a mask or not. However, in GHC a foreign call can be annotated as interruptible, in which case a throwTo will cause the RTS to attempt to cause the call to return; see the GHC documentation for more details.

Important note: the behaviour of throwTo differs from that described in the paper "Asynchronous exceptions in Haskell" (http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm). In the paper, throwTo is non-blocking; but the library implementation adopts a more synchronous design in which throwTo does not return until the exception is received by the target thread. The trade-off is discussed in Section 9 of the paper. Like any blocking operation, throwTo is therefore interruptible (see Section 5.3 of the paper). Unlike other interruptible operations, however, throwTo is always interruptible, even if it does not actually block.

There is no guarantee that the exception will be delivered promptly, although the runtime will endeavour to ensure that arbitrary delays don't occur. In GHC, an exception can only be raised when a thread reaches a safe point, where a safe point is where memory allocation occurs. Some loops do not perform any memory allocation inside the loop and therefore cannot be interrupted by a throwTo.

If the target of throwTo is the calling thread, then the behaviour is the same as throwIO, except that the exception is thrown as an asynchronous exception. This means that if there is an enclosing pure computation, which would be the case if the current IO operation is inside unsafePerformIO or unsafeInterleaveIO, that computation is not permanently replaced by the exception, but is suspended as if it had received an asynchronous exception.

Note that if throwTo is called with the current thread as the target, the exception will be thrown even if the thread is currently inside mask or uninterruptibleMask.

valueunsafeIOToSTM :: IO a -> STM a
#

Unsafely performs IO in the STM monad. Beware: this is a highly dangerous thing to do.

  • The STM implementation will often run transactions multiple times, so you need to be prepared for this if your IO has any side effects.

  • The STM implementation will abort transactions that are known to be invalid and need to be restarted. This may happen in the middle of unsafeIOToSTM, so make sure you don't acquire any resources that need releasing (exception handlers are ignored when aborting the transaction). That includes doing any IO using Handles, for example. Getting this wrong will probably lead to random deadlocks.

  • The transaction may have seen an inconsistent view of memory when the IO runs. Invariants that you expect to be true throughout your program may not be true inside a transaction, due to the way transactions are implemented. Normally this wouldn't be visible to the programmer, but using unsafeIOToSTM can expose it.

valueyield :: IO ()
#

The yield action allows (forces, in a co-operative multitasking implementation) a context-switch to any other currently runnable threads (if any), and is occasionally useful when implementing concurrency abstractions.

value(<<^) :: Arrow a => a c d -> (b -> c) -> a b d
#

Precomposition with a pure function (right-to-left variant).

value(>>^) :: Arrow a => a b c -> (c -> d) -> a b d
#

Postcomposition with a pure function.

value(^<<) :: Arrow a => (c -> d) -> a b c -> a b d
#

Postcomposition with a pure function (right-to-left variant).

value(^>>) :: Arrow a => (b -> c) -> a c d -> a b d
#

Precomposition with a pure function.

valuereturnA :: Arrow a => a b b
#

The identity arrow, which plays the role of return in arrow notation.

value(<<<) :: Category cat => cat b c -> cat a b -> cat a c
#

Right-to-left composition

value(>>>) :: Category cat => cat a b -> cat b c -> cat a c
#

Left-to-right composition

valuemodifyMVar :: MVar a -> (a -> IO (a, b)) -> IO b
#

A slight variation on modifyMVar_ that allows a value to be returned (b) in addition to the modified value of the MVar.

valuemodifyMVar_ :: MVar a -> (a -> IO a) -> IO ()
#

An exception-safe wrapper for modifying the contents of an MVar. Like withMVar, modifyMVar will replace the original contents of the MVar if an exception is raised during the operation. This function is only atomic if there are no other producers for this MVar. In other words, it cannot guarantee that, by the time modifyMVar_ gets the chance to write to the MVar, the value of the MVar has not been altered by a write operation from another thread.

valueswapMVar :: MVar a -> a -> IO a
#

Take a value from an MVar, put a new value into the MVar and return the value taken. This function is atomic only if there are no other producers for this MVar. In other words, it cannot guarantee that, by the time swapMVar gets the chance to write to the MVar, the value of the MVar has not been altered by a write operation from another thread.

valuewithMVar :: MVar a -> (a -> IO b) -> IO b
#

withMVar is an exception-safe wrapper for operating on the contents of an MVar. This operation is exception-safe: it will replace the original contents of the MVar if an exception is raised (see Control.Exception). However, it is only atomic if there are no other producers for this MVar. In other words, it cannot guarantee that, by the time withMVar gets the chance to write to the MVar, the value of the MVar has not been altered by a write operation from another thread.

valuewithMVarMasked :: MVar a -> (a -> IO b) -> IO b
#

Like withMVar, but the IO action in the second argument is executed with asynchronous exceptions masked.

valueallowInterrupt :: IO ()
#

When invoked inside mask, this function allows a masked asynchronous exception to be raised, if one exists. It is equivalent to performing an interruptible operation (see #interruptible), but does not involve any actual blocking.

When called outside mask, or inside uninterruptibleMask, this function has no effect.

valuecatches :: IO a -> [Handler a] -> IO a
#

Sometimes you want to catch two different sorts of exception. You could do something like

f = expr `catch` \ (ex :: ArithException) -> handleArith ex
         `catch` \ (ex :: IOException)    -> handleIO    ex

However, there are a couple of problems with this approach. The first is that having two exception handlers is inefficient. However, the more serious issue is that the second exception handler will catch exceptions in the first, e.g. in the example above, if handleArith throws an IOException then the second exception handler will catch it.

Instead, we provide a function catches, which would be used thus:

f = expr `catches` [Handler (\ (ex :: ArithException) -> handleArith ex),
                    Handler (\ (ex :: IOException)    -> handleIO    ex)]
valuebracket
  1. :: IO a

    computation to run first ("acquire resource")

  2. -> (a -> IO b)

    computation to run last ("release resource")

  3. -> (a -> IO c)

    computation to run in-between

  4. -> IO c
#

When you want to acquire a resource, do some work with it, and then release the resource, it is a good idea to use bracket, because bracket will install the necessary exception handler to release the resource in the event that an exception is raised during the computation. If an exception is raised, then bracket will re-raise the exception (after performing the release).

A common example is opening a file:

bracket
  (openFile "filename" ReadMode)
  (hClose)
  (\fileHandle -> do { ... })

The arguments to bracket are in this order so that we can partially apply it, e.g.:

withFile name mode = bracket (openFile name mode) hClose

Bracket wraps the release action with mask, which is sufficient to ensure that the release action executes to completion when it does not invoke any interruptible actions, even in the presence of asynchronous exceptions. For example, hClose is uninterruptible when it is not racing other uses of the handle. Similarly, closing a socket (from "network" package) is also uninterruptible under similar conditions. An example of an interruptible action is killThread. Completion of interruptible release actions can be ensured by wrapping them in uninterruptibleMask_, but this risks making the program non-responsive to Control-C, or timeouts. Another option is to run the release action asynchronously in its own thread:

void $ uninterruptibleMask_ $ forkIO $ do { ... }

The resource will be released as soon as possible, but the thread that invoked bracket will not block in an uninterruptible state.

valuebracketOnError
  1. :: IO a

    computation to run first ("acquire resource")

  2. -> (a -> IO b)

    computation to run last ("release resource")

  3. -> (a -> IO c)

    computation to run in-between

  4. -> IO c
#

Like bracket, but only performs the final action if there was an exception raised by the in-between computation.

valuebracket_ :: IO a -> IO b -> IO c -> IO c
#

A variant of bracket where the return value from the first computation is not required.

valuecatchJust
  1. :: Exception e
  2. => (e -> Maybe b)

    Predicate to select exceptions

  3. -> IO a

    Computation to run

  4. -> (b -> IO a)

    Handler

  5. -> IO a
#

The function catchJust is like catch, but it takes an extra argument which is an exception predicate, a function which selects which type of exceptions we're interested in.

catchJust (\e -> if isDoesNotExistErrorType (ioeGetErrorType e) then Just () else Nothing)
          (readFile f)
          (\_ -> do hPutStrLn stderr ("No such file: " ++ show f)
                    return "")

Any other exceptions which are not matched by the predicate are re-raised, and may be caught by an enclosing catch, catchJust, etc.

valuefinally
  1. :: IO a

    computation to run first

  2. -> IO b

    computation to run afterward (even if an exception was raised)

  3. -> IO a
#

A specialised variant of bracket with just a computation to run afterward.

valuehandle :: Exception e => (e -> IO a) -> IO a -> IO a
#

A version of catch with the arguments swapped around; useful in situations where the code for the handler is shorter. For example:

  do handle (\NonTermination -> exitWith (ExitFailure 1)) $
     ...
valuemapException :: (Exception e1, Exception e2) => (e1 -> e2) -> a -> a
#

This function maps one exception into another as proposed in the paper "A semantics for imprecise exceptions".

valueonException :: IO a -> IO b -> IO a
#

Like finally, but only performs the final action if there was an exception raised by the computation.

valuetry :: Exception e => IO a -> IO (Either e a)
#

Similar to catch, but returns an Either result which is (Right a) if no exception of type e was raised, or (Left ex) if an exception of type e was raised and its value is ex. If any other type of exception is raised then it will be propagated up to the next enclosing exception handler.

 try a = catch (Right `liftM` a) (return . Left)
valuetryJust :: Exception e => (e -> Maybe b) -> IO a -> IO (Either b a)
#

A variant of try that takes an exception predicate to select which exceptions are caught (c.f. catchJust). If the exception does not match the predicate, it is re-thrown.

value(<$!>) :: Monad m => (a -> b) -> m a -> m b
#

Strict version of Data.Functor.<$>.

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

Right-to-left composition of Kleisli arrows. (>=>), with the arguments flipped.

Note how this operator resembles function composition (.):

(.)   ::            (b ->   c) -> (a ->   b) -> a ->   c
(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
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
valuefilterM :: Applicative m => (a -> m Bool) -> [a] -> m [a]
#

This generalizes the list-based filter function.

runIdentity (filterM (Identity . p) xs) == filter p xs
Examples
Example1 expression
filterM (\x -> do      putStrLn ("Keep: " ++ show x ++ "?")      answer <- getLine      pure (answer == "y"))    [1, 2, 3]Keep: 1?yKeep: 2?nKeep: 3?y[1,3]
Example1 expression
filterM (\x -> do      putStr (show x)      x' <- readLn      pure (x == x'))    [1, 2, 3]122233[2,3]
valuefoldM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
#

The foldM function is analogous to foldl, except that its result is encapsulated in a monad. Note that foldM works from left-to-right over the list arguments. This could be an issue where (>>) and the `folded function' are not commutative.

foldM f a1 [x1, x2, ..., xm]

==

do
  a2 <- f a1 x1
  a3 <- f a2 x2
  ...
  f am xm

If right-to-left evaluation is required, the input list should be reversed.

Note: foldM is the same as foldlM

valueforever :: Applicative f => f a -> f b
#

Repeat an action indefinitely.

Examples

A common use of forever is to process input from network sockets, System.IO.Handles, and channels (e.g. Control.Concurrent.MVar.MVar and Chan).

For example, here is how we might implement an echo server, using forever both to listen for client connections on a network socket and to echo client input on client connection handles:

echoServer :: Socket -> IO ()
echoServer socket = forever $ do
  client <- accept socket
  forkFinally (echo client) (\_ -> hClose client)
  where
    echo :: Handle -> IO ()
    echo client = forever $
      hGetLine client >>= hPutStrLn client

Note that "forever" isn't necessarily non-terminating. If the action is in a MonadPlus and short-circuits after some number of iterations. then forever actually returns mzero, effectively short-circuiting its caller.

valuemapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c])
#

The mapAndUnzipM function maps its first argument over a list, returning the result as a pair of lists. This function is mainly used with complicated data structures or a state monad.

valuereplicateM :: Applicative m => Int -> m a -> m [a]
#

replicateM n act performs the action act n times, and then returns the list of results.

replicateM n (pure x) == replicate n x
Examples
Example1 expression
replicateM 3 getLinehiheyahiya["hi","heya","hiya"]
Example2 expressions
import Control.Monad.StaterunState (replicateM 3 $ state $ \s -> (s, s + 1)) 1([1,2,3],4)
valueunless :: Applicative f => Bool -> f () -> f ()
#

The reverse of when.

Examples
Example1 expression
do x <- getLine       unless (x == "hi") (putStrLn "hi!")comingupwithexamplesisdifficulthi!
Example1 expression
unless (pi > exp 1) NothingJust ()
valuefixST :: (a -> ST s a) -> ST s a
#

Allow the result of an ST computation to be used (lazily) inside the computation.

Note that if f is strict, fixST f = _|_.

value(.^.) :: Bits a => a -> a -> a
#

Infix version of xor.

valueoneBits :: FiniteBits a => a
#

A more concise version of complement zeroBits.

Example1 expression
complement (zeroBits :: Word) == (oneBits :: Word)True
Example1 expression
complement (oneBits :: Word) == (zeroBits :: Word)True

Note

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

valuebool :: a -> a -> Bool -> a
#

Case analysis for the Bool type. bool f t p evaluates to f when p is False, and evaluates to t when p is True.

This is equivalent to if p then t else f; that is, one can think of it as an if-then-else construct with its arguments reordered.

Examples

Basic usage:

Example2 expressions
bool "foo" "bar" True"bar"bool "foo" "bar" False"foo"

Confirm that bool f t p and if p then t else f are equivalent:

Example4 expressions
let p = True; f = "bar"; t = "foo"bool f t p == if p then t else fTruelet p = Falsebool f t p == if p then t else fTrue
valueconstrFields :: Constr -> [String]
#

Gets the field labels of a constructor. The list of labels is returned in the same order as they were given in the original constructor declaration.

valuefromDyn
  1. :: Typeable a
  2. => Dynamic

    the dynamically-typed object

  3. -> a

    a default value

  4. -> a

    returns: the value of the first argument, if it has the correct type, otherwise the value of the second argument.

#

Converts a Dynamic object back into an ordinary Haskell value of the correct type. See also fromDynamic.

valuefromDynamic
  1. :: Typeable a
  2. => Dynamic

    the dynamically-typed object

  3. -> Maybe a

    returns: Just a, if the dynamically-typed object has the correct type (and a is its value), or Nothing otherwise.

#

Converts a Dynamic object back into an ordinary Haskell value of the correct type. See also fromDyn.

valuefromLeft :: a -> Either a b -> a
#

Return the contents of a Left-value or a default value otherwise.

Examples

Basic usage:

Example2 expressions
fromLeft 1 (Left 3)3fromLeft 1 (Right "foo")1
valuefromRight :: b -> Either a b -> b
#

Return the contents of a Right-value or a default value otherwise.

Examples

Basic usage:

Example2 expressions
fromRight 1 (Right 3)3fromRight 1 (Left "foo")1
valueisLeft :: Either a b -> Bool
#

Return True if the given value is a Left-value, False otherwise.

Examples

Basic usage:

Example2 expressions
isLeft (Left "foo")TrueisLeft (Right 3)False

Assuming a Left value signifies some sort of error, we can use isLeft to write a very simple error-reporting function that does absolutely nothing in the case of success, and outputs "ERROR" if any error occurred.

This example shows how isLeft might be used to avoid pattern matching when one does not care about the value contained in the constructor:

Example4 expressions
import Control.Monad ( when )let report e = when (isLeft e) $ putStrLn "ERROR"report (Right 1)report (Left "parse error")ERROR
valueisRight :: Either a b -> Bool
#

Return True if the given value is a Right-value, False otherwise.

Examples

Basic usage:

Example2 expressions
isRight (Left "foo")FalseisRight (Right 3)True

Assuming a Left value signifies some sort of error, we can use isRight to write a very simple reporting function that only outputs "SUCCESS" when a computation has succeeded.

This example shows how isRight might be used to avoid pattern matching when one does not care about the value contained in the constructor:

Example4 expressions
import Control.Monad ( when )let report e = when (isRight e) $ putStrLn "SUCCESS"report (Left "parse error")report (Right 1)SUCCESS
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"]
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
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]
valueall :: Foldable t => (a -> Bool) -> t a -> Bool
#

Determines whether all elements of the structure satisfy the predicate.

Examples

Basic usage:

Example1 expression
all (> 3) []True
Example1 expression
all (> 3) [1,2]False
Example1 expression
all (> 3) [1,2,3,4,5]False
Example1 expression
all (> 3) [1..]False
Example1 expression
all (> 3) [4..]* Hangs forever *
valueand :: Foldable t => t Bool -> Bool
#

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

Examples

Basic usage:

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

Determines whether any element of the structure satisfies the predicate.

Examples

Basic usage:

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

The sum of a collection of actions using (<|>), generalizing concat.

asum is just like msum, but generalised to Alternative.

Examples

Basic usage:

Example1 expression
asum [Just "Hello", Nothing, Just "World"]Just "Hello"
valueconcat :: Foldable t => t [a] -> [a]
#

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

Examples

Basic usage:

Example1 expression
concat (Just [1, 2, 3])[1,2,3]
Example1 expression
concat (Left 42)[]
Example1 expression
concat [[1, 2, 3], [4, 5], [6], []][1,2,3,4,5,6]
valueconcatMap :: Foldable t => (a -> [b]) -> t a -> [b]
#

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

Examples

Basic usage:

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

The find function takes a predicate and a structure and returns the leftmost element of the structure matching the predicate, or Nothing if there is no such element.

Examples

Basic usage:

Example1 expression
find (> 42) [0, 5..]Just 45
Example1 expression
find (> 12) [1..7]Nothing
valuefoldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
#

Left-to-right monadic fold over the elements of a structure.

Given a structure t with elements (a, b, ..., w, x, y), the result of a fold with an operator function f is equivalent to:

foldlM f z t = do
    aa <- f z a
    bb <- f aa b
    ...
    xx <- f ww x
    yy <- f xx y
    return yy -- Just @return z@ when the structure is empty

For a Monad m, given two functions f1 :: a -> m b and f2 :: b -> m c, their Kleisli composition (f1 >=> f2) :: a -> m c is defined by:

(f1 >=> f2) a = f1 a >>= f2

Another way of thinking about foldlM is that it amounts to an application to z of a Kleisli composition:

foldlM f z t =
    flip f a >=> flip f b >=> ... >=> flip f x >=> flip f y $ z

The monadic effects of foldlM are sequenced from left to right.

If at some step the bind operator (>>=) short-circuits (as with, e.g., mzero in a MonadPlus), the evaluated effects will be from an initial segment of the element sequence. If you want to evaluate the monadic effects in right-to-left order, or perhaps be able to short-circuit after processing a tail of the sequence of elements, you'll need to use foldrM instead.

If the monadic effects don't short-circuit, the outermost application of f is to the rightmost element y, so that, ignoring effects, the result looks like a left fold:

((((z `f` a) `f` b) ... `f` w) `f` x) `f` y
Examples

Basic usage:

Example2 expressions
let f a e = do { print e ; return $ e : a }foldlM f [] [0..3]0123[3,2,1,0]
valuefoldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b
#

Right-to-left monadic fold over the elements of a structure.

Given a structure t with elements (a, b, c, ..., x, y), the result of a fold with an operator function f is equivalent to:

foldrM f z t = do
    yy <- f y z
    xx <- f x yy
    ...
    bb <- f b cc
    aa <- f a bb
    return aa -- Just @return z@ when the structure is empty

For a Monad m, given two functions f1 :: a -> m b and f2 :: b -> m c, their Kleisli composition (f1 >=> f2) :: a -> m c is defined by:

(f1 >=> f2) a = f1 a >>= f2

Another way of thinking about foldrM is that it amounts to an application to z of a Kleisli composition:

foldrM f z t = f y >=> f x >=> ... >=> f b >=> f a $ z

The monadic effects of foldrM are sequenced from right to left, and e.g. folds of infinite lists will diverge.

If at some step the bind operator (>>=) short-circuits (as with, e.g., mzero in a MonadPlus), the evaluated effects will be from a tail of the element sequence. If you want to evaluate the monadic effects in left-to-right order, or perhaps be able to short-circuit after an initial sequence of elements, you'll need to use foldlM instead.

If the monadic effects don't short-circuit, the outermost application of f is to the leftmost element a, so that, ignoring effects, the result looks like a right fold:

a `f` (b `f` (c `f` (... (x `f` (y `f` z))))).
Examples

Basic usage:

Example2 expressions
let f i acc = do { print i ; return $ i : acc }foldrM f [] [0..3]3210[0,1,2,3]
valueforM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()
#

forM_ is mapM_ with its arguments flipped. For a version that doesn't ignore the results see Data.Traversable.forM.

forM_ is just like for_, but specialised to monadic actions.

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

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

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

valuemaximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
#

The largest element of a non-empty structure with respect to the given comparison function.

Examples

Basic usage:

Example1 expression
maximumBy (compare `on` length) ["Hello", "World", "!", "Longest", "bar"]"Longest"

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

valueminimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
#

The least element of a non-empty structure with respect to the given comparison function.

Examples

Basic usage:

Example1 expression
minimumBy (compare `on` length) ["Hello", "World", "!", "Longest", "bar"]"!"

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

valuemsum :: (Foldable t, MonadPlus m) => t (m a) -> m a
#

The sum of a collection of actions using (<|>), generalizing concat.

msum is just like asum, but specialised to MonadPlus.

Examples

Basic usage, using the MonadPlus instance for Maybe:

Example1 expression
msum [Just "Hello", Nothing, Just "World"]Just "Hello"
valuenotElem :: (Foldable t, Eq a) => a -> t a -> Bool
#

notElem is the negation of elem.

Examples

Basic usage:

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

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

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

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

Examples

Basic usage:

Example1 expression
or []False
Example1 expression
or [True]True
Example1 expression
or [False]False
Example1 expression
or [True, True, False]True
Example1 expression
or (True : repeat False) -- Infinite list [True,False,False,False,...True
Example1 expression
or (repeat False)* Hangs forever *
valuesequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f ()
#

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

sequenceA_ is just like sequence_, but generalised to Applicative actions.

Examples

Basic usage:

Example1 expression
sequenceA_ [print "Hello", print "world", print "!"]"Hello""world""!"
valuesequence_ :: (Foldable t, Monad m) => t (m a) -> m ()
#

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

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

valuetraverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
#

Map each element of a structure to an Applicative action, evaluate these actions from left to right, and ignore the results. For a version that doesn't ignore the results see traverse.

traverse_ is just like mapM_, but generalised to Applicative actions.

Examples

Basic usage:

Example1 expression
traverse_ print ["Hello", "world", "!"]"Hello""world""!"
value(&) :: a -> (a -> b) -> b
#

& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $.

This is a version of flip id, where id is specialized from a -> a to (a -> b) -> (a -> b) which by the associativity of (->) is (a -> b) -> a -> b. flipping this yields a -> (a -> b) -> b which is the type signature of &

Examples
Example1 expression
5 & (+1) & show"6"
Example1 expression
sqrt $ [1 / n^2 | n <- [1..1000]] & sum & (*6)3.1406380562059946
valueapplyWhen :: Bool -> (a -> a) -> a -> a
#

applyWhen applies a function to a value if a condition is true, otherwise, it returns the value unchanged.

It is equivalent to flip (bool id).

Examples
Example1 expression
map (\x -> applyWhen (odd x) (*2) x) [1..10][2,2,6,4,10,6,14,8,18,10]
Example1 expression
map (\x -> applyWhen (length x > 6) ((++ "...") . take 3) x) ["Hi!", "This is amazing", "Hope you're doing well today!", ":D"]["Hi!","Thi...","Hop...",":D"]
Algebraic properties
valuefix :: (a -> a) -> a
#

fix f is the least fixed point of the function f, i.e. the least defined x such that f x = x.

When f is strict, this means that because, by the definition of strictness, f ⊥ = ⊥ and such the least defined fixed point of any strict function is ⊥.

Examples

We can write the factorial function using direct recursion as

Example1 expression
let fac n = if n <= 1 then 1 else n * fac (n-1) in fac 5120

This uses the fact that Haskell’s let introduces recursive bindings. We can rewrite this definition using fix,

Instead of making a recursive call, we introduce a dummy parameter rec; when used within fix, this parameter then refers to fix’s argument, hence the recursion is reintroduced.

Example1 expression
fix (\rec n -> if n <= 1 then 1 else n * rec (n-1)) 5120

Using fix, we can implement versions of repeat as fix . (:) and cycle as fix . (++)

Example1 expression
take 10 $ fix (0:)[0,0,0,0,0,0,0,0,0,0]
Example1 expression
map (fix (\rec n -> if n < 2 then n else rec (n - 1) + rec (n - 2))) [1..10][1,1,2,3,5,8,13,21,34,55]
Implementation Details

The current implementation of fix uses structural sharing

fix f = let x = f x in x

A more straightforward but non-sharing version would look like

fix f = f (fix f)
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)
value($>) :: Functor f => f a -> b -> f b
#

Flipped version of <$.

Examples

Replace the contents of a Maybe Int with a constant String:

Example1 expression
Nothing $> "foo"Nothing
Example1 expression
Just 90210 $> "foo"Just "foo"

Replace the contents of an Either Int Int with a constant String, resulting in an Either Int String:

Example1 expression
Left 8675309 $> "foo"Left 8675309
Example1 expression
Right 8675309 $> "foo"Right "foo"

Replace each element of a list with a constant String:

Example1 expression
[1,2,3] $> "foo"["foo","foo","foo"]

Replace the second element of a pair with a constant String:

Example1 expression
(1,2) $> "foo"(1,"foo")
value(<$>) :: Functor f => (a -> b) -> f a -> f b
#

An infix synonym for fmap.

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

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

Whereas $ 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)
value(<&>) :: Functor f => f a -> (a -> b) -> f b
#

Flipped version of <$>.

(<&>) = flip fmap
Examples

Apply (+1) to a list, a Just and a Right:

Example1 expression
Just 2 <&> (+1)Just 3
Example1 expression
[1,2,3] <&> (+1)[2,3,4]
Example1 expression
Right 3 <&> (+1)Right 4
valueatomicModifyIORef :: IORef a -> (a -> (a, b)) -> IO b
#

Atomically modifies the contents of an IORef.

This function is useful for using IORef in a safe way in a multithreaded program. If you only have one IORef, then using atomicModifyIORef to access and modify it will prevent race conditions.

Extending the atomicity to multiple IORefs is problematic, so it is recommended that if you need to do anything more complicated then using Control.Concurrent.MVar.MVar instead is a good idea.

Conceptually,

atomicModifyIORef ref f = do
  -- Begin atomic block
  old <- readIORef ref
  let r = f old
      new = fst r
  writeIORef ref new
  -- End atomic block
  case r of
    (_new, res) -> pure res

The actions in the section labeled "atomic block" are not subject to interference from other threads. In particular, it is impossible for the value in the IORef to change between the readIORef and writeIORef invocations.

The user-supplied function is applied to the value stored in the IORef, yielding a new value to store in the IORef and a value to return. After the new value is (lazily) stored in the IORef, atomicModifyIORef forces the result pair, but does not force either component of the result. To force both components, use atomicModifyIORef'.

Note that

atomicModifyIORef ref (_ -> undefined)

will raise an exception in the calling thread, but will also install the bottoming value in the IORef, where it may be read by other threads.

This function imposes a memory barrier, preventing reordering around the "atomic block"; see Data.IORef#memmodel for details.

valueatomicWriteIORef :: IORef a -> a -> IO ()
#

Variant of writeIORef. The prefix "atomic" relates to a fact that it imposes a reordering barrier, similar to atomicModifyIORef. Such a write will not be reordered with other reads or writes even on CPUs with weak memory model.

valuemodifyIORef :: IORef a -> (a -> a) -> IO ()
#

Mutate the contents of an IORef, combining readIORef and writeIORef. This is not an atomic update, consider using atomicModifyIORef when operating in a multithreaded environment.

Be warned that modifyIORef does not apply the function strictly. This means if the program calls modifyIORef many times, but seldom uses the value, thunks will pile up in memory resulting in a space leak. This is a common mistake made when using an IORef as a counter. For example, the following will likely produce a stack overflow:

ref <- newIORef 0
replicateM_ 1000000 $ modifyIORef ref (+1)
readIORef ref >>= print

To avoid this problem, use modifyIORef' instead.

valueisSubsequenceOf :: Eq a => [a] -> [a] -> Bool
#

The isSubsequenceOf function takes two lists and returns True if all the elements of the first list occur, in order, in the second. The elements do not have to occur consecutively.

isSubsequenceOf x y is equivalent to x `elem` (subsequences y).

Note: isSubsequenceOf is often used in infix form.

Examples
Example1 expression
"GHC" `isSubsequenceOf` "The Glorious Haskell Compiler"True
Example1 expression
['a','d'..'z'] `isSubsequenceOf` ['a'..'z']True
Example1 expression
[1..10] `isSubsequenceOf` [10,9..0]False

For the result to be True, the first list must be finite; for the result to be False, the second list must be finite:

Example1 expression
[0,2..10] `isSubsequenceOf` [0..]True
Example1 expression
[0..] `isSubsequenceOf` [0,2..10]False
Example1 expression
[0,2..] `isSubsequenceOf` [0..]* Hangs forever*
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]
valuefromJust :: HasCallStack => Maybe a -> a
#

The fromJust function extracts the element out of a Just and throws an error if its argument is Nothing.

Examples

Basic usage:

Example1 expression
fromJust (Just 1)1
Example1 expression
2 * (fromJust (Just 10))20
Example1 expression
2 * (fromJust Nothing)*** Exception: Maybe.fromJust: Nothing...

WARNING: This function is partial. You can use case-matching instead.

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]
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]
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""
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
value(\\) :: Eq a => [a] -> [a] -> [a]
#

The \\ function is list difference (non-associative). In the result of xs \\ ys, the first occurrence of each element of ys in turn (if any) has been removed from xs. Thus (xs ++ ys) \\ xs == ys.

It is a special case of deleteFirstsBy, which allows the programmer to supply their own equality test.

Examples
Example1 expression
"Hello World!" \\ "ell W""Hoorld!"

The second list must be finite, but the first may be infinite.

Example1 expression
take 5 ([0..] \\ [2..4])[0,1,5,6,7]
Example1 expression
take 5 ([0..] \\ [2..])* Hangs forever *
valuedelete :: Eq a => a -> [a] -> [a]
#

\mathcal{O}(n). delete x removes the first occurrence of x from its list argument.

It is a special case of deleteBy, which allows the programmer to supply their own equality test.

Examples
Example1 expression
delete 'a' "banana""bnana"
Example1 expression
delete "not" ["haskell", "is", "not", "awesome"]["haskell","is","awesome"]
valuedeleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]
#

\mathcal{O}(n). The deleteBy function behaves like delete, but takes a user-supplied equality predicate.

Examples
Example1 expression
deleteBy (<=) 4 [1..10][1,2,3,5,6,7,8,9,10]
Example1 expression
deleteBy (/=) 5 [5, 5, 4, 3, 5, 2][5,5,3,5,2]
valuedeleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
#

The deleteFirstsBy function takes a predicate and two lists and returns the first list with the first occurrence of each element of the second list removed. This is the non-overloaded version of (\\).

(\\) == deleteFirstsBy (==)

The second list must be finite, but the first may be infinite.

Examples
Example1 expression
deleteFirstsBy (>) [1..10] [3, 4, 5][4,5,6,7,8,9,10]
Example1 expression
deleteFirstsBy (/=) [1..10] [1, 3, 5][4,5,6,7,8,9,10]
valuedropWhileEnd :: (a -> Bool) -> [a] -> [a]
#

The dropWhileEnd function drops the largest suffix of a list in which the given predicate holds for all elements.

Laziness

This function is lazy in spine, but strict in elements, which makes it different from reverse . dropWhile p . reverse, which is strict in spine, but lazy in elements. For instance:

Example1 expression
take 1 (dropWhileEnd (< 0) (1 : undefined))[1]
Example1 expression
take 1 (reverse $ dropWhile (< 0) $ reverse (1 : undefined))*** Exception: Prelude.undefined

but on the other hand

Example1 expression
last (dropWhileEnd (< 0) [undefined, 1])*** Exception: Prelude.undefined
Example1 expression
last (reverse $ dropWhile (< 0) $ reverse [undefined, 1])1
Examples
Example1 expression
dropWhileEnd isSpace "foo\n""foo"
Example2 expressions
dropWhileEnd isSpace "foo bar""foo bar"dropWhileEnd (> 10) [1..20][1,2,3,4,5,6,7,8,9,10]
valueelemIndex :: Eq a => a -> [a] -> Maybe Int
#

The elemIndex function returns the index of the first element in the given list which is equal (by ==) to the query element, or Nothing if there is no such element. For the result to be Nothing, the list must be finite.

Examples
Example1 expression
elemIndex 4 [0..]Just 4
Example1 expression
elemIndex 'o' "haskell"Nothing
Example1 expression
elemIndex 0 [1..]* hangs forever *
valueelemIndices :: Eq a => a -> [a] -> [Int]
#

The elemIndices function extends elemIndex, by returning the indices of all elements equal to the query element, in ascending order.

Examples
Example1 expression
elemIndices 'o' "Hello World"[4,7]
Example1 expression
elemIndices 1 [1, 2, 3, 1, 2, 3][0,3]
valuefindIndex :: (a -> Bool) -> [a] -> Maybe Int
#

The findIndex function takes a predicate and a list and returns the index of the first element in the list satisfying the predicate, or Nothing if there is no such element. For the result to be Nothing, the list must be finite.

Examples
Example1 expression
findIndex isSpace "Hello World!"Just 5
Example1 expression
findIndex odd [0, 2, 4, 6]Nothing
Example1 expression
findIndex even [1..]Just 1
Example1 expression
findIndex odd [0, 2 ..]* hangs forever *
valuefindIndices :: (a -> Bool) -> [a] -> [Int]
#

The findIndices function extends findIndex, by returning the indices of all elements satisfying the predicate, in ascending order.

Examples
Example1 expression
findIndices (`elem` "aeiou") "Hello World!"[1,4,7]
Example1 expression
findIndices (\l -> length l > 3) ["a", "bcde", "fgh", "ijklmnop"][1,3]
valuegenericLength :: Num i => [a] -> i
#

\mathcal{O}(n). The genericLength function is an overloaded version of length. In particular, instead of returning an Int, it returns any type which is an instance of Num. It is, however, less efficient than length.

Examples
Example2 expressions
genericLength [1, 2, 3] :: Int3genericLength [1, 2, 3] :: Float3.0

Users should take care to pick a return type that is wide enough to contain the full length of the list. If the width is insufficient, the overflow behaviour will depend on the (+) implementation in the selected Num instance. The following example overflows because the actual list length of 200 lies outside of the Int8 range of -128..127.

Example1 expression
genericLength [1..200] :: Int8-56
valuegroupBy :: (a -> a -> Bool) -> [a] -> [[a]]
#

The groupBy function is the non-overloaded version of group.

When a supplied relation is not transitive, it is important to remember that equality is checked against the first element in the group, not against the nearest neighbour:

Example1 expression
groupBy (\a b -> b - a < 5) [0..19][[0,1,2,3,4],[5,6,7,8,9],[10,11,12,13,14],[15,16,17,18,19]]

It's often preferable to use Data.List.NonEmpty.groupBy, which provides type-level guarantees of non-emptiness of inner lists.

Examples
Example1 expression
groupBy (/=) [1, 1, 1, 2, 3, 1, 4, 4, 5][[1],[1],[1,2,3],[1,4,4,5]]
Example1 expression
groupBy (>) [1, 3, 5, 1, 4, 2, 6, 5, 4][[1],[3],[5,1,4,2],[6,5,4]]
Example1 expression
groupBy (const not) [True, False, True, False, False, False, True][[True,False],[True,False,False,False],[True]]
valueinits :: [a] -> [[a]]
#

The inits function returns all initial segments of the argument, shortest first.

inits is semantically equivalent to map reverse . scanl (flip (:)) [], but under the hood uses a queue to amortize costs of reverse.

Laziness

Note that inits has the following strictness property: inits (xs ++ _|_) = inits xs ++ _|_

In particular, inits _|_ = [] : _|_

Examples
Example1 expression
inits "abc"["","a","ab","abc"]
Example1 expression
inits [][[]]

inits is productive on infinite lists:

Example1 expression
take 5 $ inits [1..][[],[1],[1,2],[1,2,3],[1,2,3,4]]
valueinsert :: Ord a => a -> [a] -> [a]
#

\mathcal{O}(n). The insert function takes an element and a list and inserts the element into the list at the first position where it is less than or equal to the next element. In particular, if the list is sorted before the call, the result will also be sorted. It is a special case of insertBy, which allows the programmer to supply their own comparison function.

Examples
Example1 expression
insert (-1) [1, 2, 3][-1,1,2,3]
Example1 expression
insert 'd' "abcefg""abcdefg"
Example1 expression
insert 4 [1, 2, 3, 5, 6, 7][1,2,3,4,5,6,7]
valueinsertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]
#

\mathcal{O}(n). The non-overloaded version of insert.

Examples
Example1 expression
insertBy (\x y -> compare (length x) (length y)) [1, 2] [[1], [1, 2, 3], [1, 2, 3, 4]][[1],[1,2],[1,2,3],[1,2,3,4]]
valueintercalate :: [a] -> [[a]] -> [a]
#

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

Laziness

intercalate has the following properties:

Example1 expression
take 5 (intercalate undefined ("Lorem" : undefined))"Lorem"
Example1 expression
take 6 (intercalate ", " ("Lorem" : undefined))"Lorem*** Exception: Prelude.undefined
Examples
Example1 expression
intercalate ", " ["Lorem", "ipsum", "dolor"]"Lorem, ipsum, dolor"
Example1 expression
intercalate [0, 1] [[2, 3], [4, 5, 6], []][2,3,0,1,4,5,6,0,1]
Example1 expression
intercalate [1, 2, 3] [[], []][1,2,3]
valueintersect :: Eq a => [a] -> [a] -> [a]
#

The intersect function takes the list intersection of two lists. It is a special case of intersectBy, which allows the programmer to supply their own equality test.

Examples
Example1 expression
[1,2,3,4] `intersect` [2,4,6,8][2,4]

If equal elements are present in both lists, an element from the first list will be used, and all duplicates from the second list quashed:

Example2 expressions
import Data.Semigroupintersect [Arg () "dog"] [Arg () "cow", Arg () "cat"][Arg () "dog"]

However if the first list contains duplicates, so will the result.

Example2 expressions
"coot" `intersect` "heron""oo""heron" `intersect` "coot""o"

If the second list is infinite, intersect either hangs or returns its first argument in full. Otherwise if the first list is infinite, intersect might be productive:

Example4 expressions
intersect [100..] [0..][100,101,102,103...intersect [0] [1..]* Hangs forever *intersect [1..] [0]* Hangs forever *intersect (cycle [1..3]) [2][2,2,2,2...
valueintersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
#

The intersectBy function is the non-overloaded version of intersect. It is productive for infinite arguments only if the first one is a subset of the second.

valueintersperse :: a -> [a] -> [a]
#

\mathcal{O}(n). The intersperse function takes an element and a list and `intersperses' that element between the elements of the list.

Laziness

intersperse has the following properties

Example1 expression
take 1 (intersperse undefined ('a' : undefined))"a"
Example1 expression
take 2 (intersperse ',' ('a' : undefined))"a*** Exception: Prelude.undefined
Examples
Example1 expression
intersperse ',' "abcde""a,b,c,d,e"
Example1 expression
intersperse 1 [3, 4, 5][3,1,4,1,5]
valueisInfixOf :: Eq a => [a] -> [a] -> Bool
#

The isInfixOf function takes two lists and returns True iff the first list is contained, wholly and intact, anywhere within the second.

Examples
Example1 expression
isInfixOf "Haskell" "I really like Haskell."True
Example1 expression
isInfixOf "Ial" "I really like Haskell."False

For the result to be True, the first list must be finite; for the result to be False, the second list must be finite:

Example1 expression
[20..50] `isInfixOf` [0..]True
Example1 expression
[0..] `isInfixOf` [20..50]False
Example1 expression
[0..] `isInfixOf` [0..]* Hangs forever *
valueisPrefixOf :: Eq a => [a] -> [a] -> Bool
#

\mathcal{O}(\min(m,n)). The isPrefixOf function takes two lists and returns True iff the first list is a prefix of the second.

Examples
Example1 expression
"Hello" `isPrefixOf` "Hello World!"True
Example1 expression
"Hello" `isPrefixOf` "Wello Horld!"False

For the result to be True, the first list must be finite; False, however, results from any mismatch:

Example1 expression
[0..] `isPrefixOf` [1..]False
Example1 expression
[0..] `isPrefixOf` [0..99]False
Example1 expression
[0..99] `isPrefixOf` [0..]True
Example1 expression
[0..] `isPrefixOf` [0..]* Hangs forever *

isPrefixOf shortcuts when the first argument is empty:

Example1 expression
isPrefixOf [] undefinedTrue
valueisSuffixOf :: Eq a => [a] -> [a] -> Bool
#

The isSuffixOf function takes two lists and returns True iff the first list is a suffix of the second.

Examples
Example1 expression
"ld!" `isSuffixOf` "Hello World!"True
Example1 expression
"World" `isSuffixOf` "Hello World!"False

The second list must be finite; however the first list may be infinite:

Example1 expression
[0..] `isSuffixOf` [0..99]False
Example1 expression
[0..99] `isSuffixOf` [0..]* Hangs forever *
valuelines :: String -> [String]
#

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

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

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

\mathcal{O}(n^2). The nub function removes duplicate elements from a list. In particular, it keeps only the first occurrence of each element. (The name nub means `essence'.) It is a special case of nubBy, which allows the programmer to supply their own equality test.

If there exists instance Ord a, it's faster to use nubOrd from the containers package (link to the latest online documentation), which takes only \mathcal{O}(n \log d) time where d is the number of distinct elements in the list.

Another approach to speed up nub is to use map Data.List.NonEmpty.head . Data.List.NonEmpty.group . sort, which takes \mathcal{O}(n \log n) time, requires instance Ord a and doesn't preserve the order.

Examples
Example1 expression
nub [1,2,3,4,3,2,1,2,4,3,5][1,2,3,4,5]
Example1 expression
nub "hello, world!""helo, wrd!"
valuenubBy :: (a -> a -> Bool) -> [a] -> [a]
#

The nubBy function behaves just like nub, except it uses a user-supplied equality predicate instead of the overloaded (==) function.

Examples
Example1 expression
nubBy (\x y -> mod x 3 == mod y 3) [1,2,4,5,6][1,2,6]
Example1 expression
nubBy (/=) [2, 7, 1, 8, 2, 8, 1, 8, 2, 8][2,2,2]
Example1 expression
nubBy (>) [1, 2, 3, 2, 1, 5, 4, 5, 3, 2][1,2,3,5,5]
valuepartition :: (a -> Bool) -> [a] -> ([a], [a])
#

The partition function takes a predicate and a list, and returns the pair of lists of elements which do and do not satisfy the predicate, respectively; i.e.,

partition p xs == (filter p xs, filter (not . p) xs)
Examples
Example1 expression
partition (`elem` "aeiou") "Hello World!"("eoo","Hll Wrld!")
Example1 expression
partition even [1..10]([2,4,6,8,10],[1,3,5,7,9])
Example1 expression
partition (< 5) [1..10]([1,2,3,4],[5,6,7,8,9,10])
valuepermutations :: [a] -> [[a]]
#

The permutations function returns the list of all permutations of the argument.

Note that the order of permutations is not lexicographic. It satisfies the following property:

map (take n) (take (product [1..n]) (permutations ([1..n] ++ undefined))) == permutations [1..n]
Laziness

The permutations function is maximally lazy: for each n, the value of permutations xs starts with those permutations that permute take n xs and keep drop n xs.

Examples
Example1 expression
permutations "abc"["abc","bac","cba","bca","cab","acb"]
Example1 expression
permutations [1, 2][[1,2],[2,1]]
Example1 expression
permutations [][[]]

This function is productive on infinite inputs:

Example1 expression
take 6 $ map (take 3) $ permutations ['a'..]["abc","bac","cba","bca","cab","acb"]
valuesingleton :: a -> [a]
#

Construct a list from a single element.

Examples
Example1 expression
singleton True[True]
Example1 expression
singleton [1, 2, 3][[1,2,3]]
Example1 expression
singleton 'c'"c"
valuesort :: Ord a => [a] -> [a]
#

The sort function implements a stable sorting algorithm. It is a special case of sortBy, which allows the programmer to supply their own comparison function.

Elements are arranged from lowest to highest, keeping duplicates in the order they appeared in the input.

The argument must be finite.

Examples
Example1 expression
sort [1,6,4,3,2,5][1,2,3,4,5,6]
Example1 expression
sort "haskell""aehklls"
Example2 expressions
import Data.Semigroup(Arg(..))sort [Arg ":)" 0, Arg ":D" 0, Arg ":)" 1, Arg ":3" 0, Arg ":D" 1][Arg ":)" 0,Arg ":)" 1,Arg ":3" 0,Arg ":D" 0,Arg ":D" 1]
valuesortBy :: (a -> a -> Ordering) -> [a] -> [a]
#

The sortBy function is the non-overloaded version of sort. The argument must be finite.

The supplied comparison relation is supposed to be reflexive and antisymmetric, otherwise, e. g., for _ _ -> GT, the ordered list simply does not exist. The relation is also expected to be transitive: if it is not then sortBy might fail to find an ordered permutation, even if it exists.

Examples
Example1 expression
sortBy (\(a,_) (b,_) -> compare a b) [(2, "world"), (4, "!"), (1, "Hello")][(1,"Hello"),(2,"world"),(4,"!")]
valuesortOn :: Ord b => (a -> b) -> [a] -> [a]
#

Sort a list by comparing the results of a key function applied to each element. sortOn f is equivalent to sortBy (comparing f), but has the performance advantage of only evaluating f once for each element in the input list. This is called the decorate-sort-undecorate paradigm, or Schwartzian transform.

Elements are arranged from lowest to highest, keeping duplicates in the order they appeared in the input.

The argument must be finite.

Examples
Example1 expression
sortOn fst [(2, "world"), (4, "!"), (1, "Hello")][(1,"Hello"),(2,"world"),(4,"!")]
Example1 expression
sortOn length ["jim", "creed", "pam", "michael", "dwight", "kevin"]["jim","pam","creed","kevin","dwight","michael"]
Performance notes

This function minimises the projections performed, by materialising the projections in an intermediate list.

For trivial projections, you should prefer using sortBy with comparing, for example:

Example1 expression
sortBy (comparing fst) [(3, 1), (2, 2), (1, 3)][(1,3),(2,2),(3,1)]

Or, for the exact same API as sortOn, you can use `sortBy . comparing`:

Example1 expression
(sortBy . comparing) fst [(3, 1), (2, 2), (1, 3)][(1,3),(2,2),(3,1)]
valuestripPrefix :: Eq a => [a] -> [a] -> Maybe [a]
#

\mathcal{O}(\min(m,n)). The stripPrefix function drops the given prefix from a list. It returns Nothing if the list did not start with the prefix given, or Just the list after the prefix, if it does.

Examples
Example1 expression
stripPrefix "foo" "foobar"Just "bar"
Example1 expression
stripPrefix "foo" "foo"Just ""
Example1 expression
stripPrefix "foo" "barfoo"Nothing
Example1 expression
stripPrefix "foo" "barfoobaz"Nothing
valuesubsequences :: [a] -> [[a]]
#

The subsequences function returns the list of all subsequences of the argument.

Laziness

subsequences does not look ahead unless it must:

Example2 expressions
take 1 (subsequences undefined)[[]]take 2 (subsequences ('a' : undefined))["","a"]
Examples
Example1 expression
subsequences "abc"["","a","b","ab","c","ac","bc","abc"]

This function is productive on infinite inputs:

Example1 expression
take 8 $ subsequences ['a'..]["","a","b","ab","c","ac","bc","abc"]
valuetails :: [a] -> [[a]]
#

\mathcal{O}(n). The tails function returns all final segments of the argument, longest first.

Laziness

Note that tails has the following strictness property: tails _|_ = _|_ : _|_

Example1 expression
tails undefined[*** Exception: Prelude.undefined
Example1 expression
drop 1 (tails [undefined, 1, 2])[[1, 2], [2], []]
Examples
Example1 expression
tails "abc"["abc","bc","c",""]
Example1 expression
tails [1, 2, 3][[1,2,3],[2,3],[3],[]]
Example1 expression
tails [][[]]
valuetranspose :: [[a]] -> [[a]]
#

The transpose function transposes the rows and columns of its argument.

Laziness

transpose is lazy in its elements

Example1 expression
take 1 (transpose ['a' : undefined, 'b' : undefined])["ab"]
Examples
Example1 expression
transpose [[1,2,3],[4,5,6]][[1,4],[2,5],[3,6]]

If some of the rows are shorter than the following rows, their elements are skipped:

Example1 expression
transpose [[10,11],[20],[],[30,31,32]][[10,20,30],[11,31],[32]]

For this reason the outer list must be finite; otherwise transpose hangs:

Example1 expression
transpose (repeat [])* Hangs forever *
valueunfoldr :: (b -> Maybe (a, b)) -> b -> [a]
#

The unfoldr function is a `dual' to foldr: while foldr reduces a list to a summary value, unfoldr builds a list from a seed value. The function takes the element and returns Nothing if it is done producing the list or returns Just (a,b), in which case, a is a prepended to the list and b is used as the next element in a recursive call. For example,

iterate f == unfoldr (\x -> Just (x, f x))

In some cases, unfoldr can undo a foldr operation:

unfoldr f' (foldr f z xs) == xs

if the following holds:

f' (f x y) = Just (x,y)
f' z       = Nothing
Laziness
Example1 expression
take 1 (unfoldr (\x -> Just (x, undefined)) 'a')"a"
Examples
Example1 expression
unfoldr (\b -> if b == 0 then Nothing else Just (b, b-1)) 10[10,9,8,7,6,5,4,3,2,1]
Example1 expression
take 10 $ unfoldr (\(x, y) -> Just (x, (y, x + y))) (0, 1)[0,1,1,2,3,5,8,13,21,54]
valueunion :: Eq a => [a] -> [a] -> [a]
#

The union function returns the list union of the two lists. It is a special case of unionBy, which allows the programmer to supply their own equality test.

Examples
Example1 expression
"dog" `union` "cow""dogcw"

If equal elements are present in both lists, an element from the first list will be used. If the second list contains equal elements, only the first one will be retained:

Example3 expressions
import Data.Semigroup(Arg(..))union [Arg () "dog"] [Arg () "cow"][Arg () "dog"]union [] [Arg () "dog", Arg () "cow"][Arg () "dog"]

However if the first list contains duplicates, so will the result:

Example2 expressions
"coot" `union` "duck""cootduk""duck" `union` "coot""duckot"

union is productive even if both arguments are infinite.

Example1 expression
[0, 2 ..] `union` [1, 3 ..][0,2,4,6,8,10,12..
valueunionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
#

The unionBy function is the non-overloaded version of union. Both arguments may be infinite.

Examples
Example1 expression
unionBy (>) [3, 4, 5] [1, 2, 3, 4, 5, 6][3,4,5,4,5,6]
Example2 expressions
import Data.Semigroup (Arg(..))unionBy (/=) [Arg () "Saul"] [Arg () "Kim"][Arg () "Saul", Arg () "Kim"]
valueunlines :: [String] -> String
#

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

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

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

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

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

unwords is neither left nor right inverse of words:

Example2 expressions
words (unwords [" "])[]unwords (words "foo\nbar")"foo bar"
Examples
Example1 expression
unwords ["Lorem", "ipsum", "dolor"]"Lorem ipsum dolor"
Example1 expression
unwords ["foo", "bar", "", "baz"]"foo bar  baz"
valueunzip4 :: [(a, b, c, d)] -> ([a], [b], [c], [d])
#

The unzip4 function takes a list of quadruples and returns four lists, analogous to unzip.

valueunzip5 :: [(a, b, c, d, e)] -> ([a], [b], [c], [d], [e])
#

The unzip5 function takes a list of five-tuples and returns five lists, analogous to unzip.

valueunzip6 :: [(a, b, c, d, e, f)] -> ([a], [b], [c], [d], [e], [f])
#

The unzip6 function takes a list of six-tuples and returns six lists, analogous to unzip.

valueunzip7 :: [(a, b, c, d, e, f, g)] -> ([a], [b], [c], [d], [e], [f], [g])
#

The unzip7 function takes a list of seven-tuples and returns seven lists, analogous to unzip.

valuewords :: String -> [String]
#

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

Examples
Example1 expression
words "Lorem ipsum\ndolor"["Lorem","ipsum","dolor"]
Example1 expression
words " foo bar "["foo","bar"]
valuezip4 :: [a] -> [b] -> [c] -> [d] -> [(a, b, c, d)]
#

The zip4 function takes four lists and returns a list of quadruples, analogous to zip. It is capable of list fusion, but it is restricted to its first list argument and its resulting list.

valuezip5 :: [a] -> [b] -> [c] -> [d] -> [e] -> [(a, b, c, d, e)]
#

The zip5 function takes five lists and returns a list of five-tuples, analogous to zip. It is capable of list fusion, but it is restricted to its first list argument and its resulting list.

valuezip6 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [(a, b, c, d, e, f)]
#

The zip6 function takes six lists and returns a list of six-tuples, analogous to zip. It is capable of list fusion, but it is restricted to its first list argument and its resulting list.

valuezip7
  1. :: [a]
  2. -> [b]
  3. -> [c]
  4. -> [d]
  5. -> [e]
  6. -> [f]
  7. -> [g]
  8. -> [(a, b, c, d, e, f, g)]
#

The zip7 function takes seven lists and returns a list of seven-tuples, analogous to zip. It is capable of list fusion, but it is restricted to its first list argument and its resulting list.

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

The zipWith4 function takes a function which combines four elements, as well as four lists and returns a list of their point-wise combination, analogous to zipWith. It is capable of list fusion, but it is restricted to its first list argument and its resulting list.

valuezipWith5
  1. :: a -> b -> c -> d -> e -> f
  2. -> [a]
  3. -> [b]
  4. -> [c]
  5. -> [d]
  6. -> [e]
  7. -> [f]
#

The zipWith5 function takes a function which combines five elements, as well as five lists and returns a list of their point-wise combination, analogous to zipWith. It is capable of list fusion, but it is restricted to its first list argument and its resulting list.

valuezipWith6
  1. :: a -> b -> c -> d -> e -> f -> g
  2. -> [a]
  3. -> [b]
  4. -> [c]
  5. -> [d]
  6. -> [e]
  7. -> [f]
  8. -> [g]
#

The zipWith6 function takes a function which combines six elements, as well as six lists and returns a list of their point-wise combination, analogous to zipWith. It is capable of list fusion, but it is restricted to its first list argument and its resulting list.

valuezipWith7
  1. :: a -> b -> c -> d -> e -> f -> g -> h
  2. -> [a]
  3. -> [b]
  4. -> [c]
  5. -> [d]
  6. -> [e]
  7. -> [f]
  8. -> [g]
  9. -> [h]
#

The zipWith7 function takes a function which combines seven elements, as well as seven lists and returns a list of their point-wise combination, analogous to zipWith. It is capable of list fusion, but it is restricted to its first list argument and its resulting list.

valueclamp :: Ord a => (a, a) -> a -> a
#
clamp (low, high) a = min high (max a low)

Function for ensuring the value a is within the inclusive bounds given by low and high. If it is, a is returned unchanged. The result is otherwise low if a <= low, or high if high <= a.

When clamp is used at Double and Float, it has NaN propagating semantics in its second argument. That is, clamp (l,h) NaN = NaN, but clamp (NaN, NaN) x = x.

Example1 expression
clamp (0, 10) 22
Example1 expression
clamp ('a', 'm') 'x''m'
valuecomparing :: Ord a => (b -> a) -> b -> b -> Ordering
#
comparing p x y = compare (p x) (p y)

Useful combinator for use in conjunction with the xxxBy family of functions from Data.List, for example:

  ... sortBy (comparing fst) ...
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
valuemodifySTRef :: STRef s a -> (a -> a) -> ST s ()
#

Mutate the contents of an STRef.

Example1 expression
:{runST (do    ref <- newSTRef ""    modifySTRef ref (const "world")    modifySTRef ref (++ "!")    modifySTRef ref ("Hello, " ++)    readSTRef ref ):}"Hello, world!"

Be warned that modifySTRef does not apply the function strictly. This means if the program calls modifySTRef many times, but seldom uses the value, thunks will pile up in memory resulting in a space leak. This is a common mistake made when using an STRef as a counter. For example, the following will leak memory and may produce a stack overflow:

Example2 expressions
import GHC.Internal.Control.Monad (replicateM_):{print (runST (do    ref <- newSTRef 0    replicateM_ 1000 $ modifySTRef ref (+1)    readSTRef ref )):}1000

To avoid this problem, use modifySTRef' instead.

valuestimesIdempotent :: Integral b => b -> a -> a
#

This is a valid definition of stimes for an idempotent Semigroup.

When x <> x = x, this definition should be preferred, because it works in \mathcal{O}(1) rather than \mathcal{O}(\log n).

valuestimesIdempotentMonoid :: (Integral b, Monoid a) => b -> a -> a
#

This is a valid definition of stimes for an idempotent Monoid.

When x <> x = x, this definition should be preferred, because it works in \mathcal{O}(1) rather than \mathcal{O}(\log n)

valueforM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b)
#

forM is mapM with its arguments flipped. For a version that ignores the results see Data.Foldable.forM_.

valuemapAccumL :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)
#

The mapAccumL function behaves like a combination of fmap and foldl; it applies a function to each element of a structure, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new structure.

Examples

Basic usage:

Example1 expression
mapAccumL (\a b -> (a + b, a)) 0 [1..10](55,[0,1,3,6,10,15,21,28,36,45])
Example1 expression
mapAccumL (\a b -> (a <> show b, a)) "0" [1..5]("012345",["0","01","012","0123","01234"])
valuemapAccumM
  1. :: (Monad m, Traversable t)
  2. => s -> a -> m (s, b)
  3. -> s
  4. -> t a
  5. -> m (s, t b)
#

The mapAccumM function behaves like a combination of mapM and mapAccumL that traverses the structure while evaluating the actions and passing an accumulating parameter from left to right. It returns a final value of this accumulator together with the new structure. The accumulator is often used for caching the intermediate results of a computation.

Examples

Basic usage:

Example2 expressions
let expensiveDouble a = putStrLn ("Doubling " <> show a) >> pure (2 * a):{mapAccumM (\cache a -> case lookup a cache of    Nothing -> expensiveDouble a >>= \double -> pure ((a, double):cache, double)    Just double -> pure (cache, double)    ) [] [1, 2, 3, 1, 2, 3]:}Doubling 1Doubling 2Doubling 3([(3,6),(2,4),(1,2)],[2,4,6,2,4,6])
valuemapAccumR :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)
#

The mapAccumR function behaves like a combination of fmap and foldr; it applies a function to each element of a structure, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new structure.

Examples

Basic usage:

Example1 expression
mapAccumR (\a b -> (a + b, a)) 0 [1..10](55,[54,52,49,45,40,34,27,19,10,0])
Example1 expression
mapAccumR (\a b -> (a <> show b, a)) "0" [1..5]("054321",["05432","0543","054","05","0"])
valuecurry :: ((a, b) -> c) -> a -> b -> c
#

Convert an uncurried function to a curried function.

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

Extract the first component of a pair.

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

Extract the second component of a pair.

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

Swap the components of a pair.

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]

Applies a type to a function type. Returns: Just u if the first argument represents a function of type t -> u and the second argument represents a function of type t. Otherwise, returns Nothing.

valuesplitTyConApp :: TypeRep -> (TyCon, [TypeRep])
#

Splits a type constructor application. Note that if the type constructor is polymorphic, this will not return the kinds that were used.

valuetypeRep :: Typeable a => proxy a -> TypeRep
#

Takes a value of type a and returns a concrete representation of that type.

valuenewUnique :: IO Unique
#

Creates a new object of type Unique. The value returned will not compare equal to any other value of type Unique returned by previous calls to newUnique. There is no limit on the number of times newUnique may be called.

valuetraceEvent :: String -> a -> a
#

The traceEvent function behaves like trace with the difference that the message is emitted to the eventlog, if eventlog profiling is available and enabled at runtime.

It is suitable for use in pure code. In an IO context use traceEventIO instead.

Note that when using GHC's SMP runtime, it is possible (but rare) to get duplicate events emitted if two CPUs simultaneously evaluate the same thunk that uses traceEvent.

valuetraceIO :: String -> IO ()
#

The traceIO function outputs the trace message from the IO monad. This sequences the output with respect to other IO actions.

valuetraceId :: String -> String
#

Like trace but returns the message instead of a third value.

Example1 expression
traceId "hello"hello"hello"
valuetraceM :: Applicative f => String -> f ()
#

Like trace but returning unit in an arbitrary Applicative context. Allows for convenient use in do-notation.

Note that the application of traceM is not an action in the Applicative context, as traceIO is in the IO type. While the fresh bindings in the following example will force the traceM expressions to be reduced every time the do-block is executed, traceM "not crashed" would only be reduced once, and the message would only be printed once. If your monad is in MonadIO, liftIO . traceIO may be a better option.

Example1 expression
:{do    x <- Just 3    traceM ("x: " ++ show x)    y <- pure 12    traceM ("y: " ++ show y)    pure (x*2 + y):}x: 3y: 12Just 18
valuetraceMarker :: String -> a -> a
#

The traceMarker function emits a marker to the eventlog, if eventlog profiling is available and enabled at runtime. The String is the name of the marker. The name is just used in the profiling tools to help you keep clear which marker is which.

This function is suitable for use in pure code. In an IO context use traceMarkerIO instead.

Note that when using GHC's SMP runtime, it is possible (but rare) to get duplicate events emitted if two CPUs simultaneously evaluate the same thunk that uses traceMarker.

valuetraceShow :: Show a => a -> b -> b
#

Like trace, but uses show on the argument to convert it to a String.

This makes it convenient for printing the values of interesting variables or expressions inside a function. For example, here we print the values of the variables x and y:

Example1 expression
let f x y = traceShow ("x", x, "y", y) (x + y) in f (1+2) 5("x",3,"y",5)8

Note in this example we also create simple labels just by including some strings.

valuetraceShowId :: Show a => a -> a
#

Like traceShow but returns the shown value instead of a third value.

Example1 expression
traceShowId (1+2+3, "hello" ++ "world")(6,"helloworld")(6,"helloworld")
valuetraceShowM :: (Show a, Applicative f) => a -> f ()
#

Like traceM, but uses show on the argument to convert it to a String.

Example1 expression
:{do    x <- Just 3    traceShowM x    y <- pure 12    traceShowM y    pure (x*2 + y):}312Just 18
valuetraceShowWith :: Show b => (a -> b) -> a -> a
#

Like traceWith, but uses show on the result of the function to convert it to a String.

Example1 expression
traceShowWith length [1,2,3]3[1,2,3]
valuetraceStack :: String -> a -> a
#

like trace, but additionally prints a call stack if one is available.

In the current GHC implementation, the call stack is only available if the program was compiled with -prof; otherwise traceStack behaves exactly like trace. Entries in the call stack correspond to SCC annotations, so it is a good idea to use -fprof-auto or -fprof-auto-calls to add SCC annotations automatically.

valuetraceWith :: (a -> String) -> a -> a
#

Like trace, but outputs the result of calling a function on the argument.

Example1 expression
traceWith fst ("hello","world")hello("hello","world")
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.

valuethrow :: (HasCallStack, Exception e) => e -> a
#

Throw an exception. Exceptions may be thrown from purely functional code, but may only be caught within the IO monad.

WARNING: You may want to use throwIO instead so that your pure code stays exception-free.

valuegroupWith :: Ord b => (a -> b) -> [a] -> [[a]]
#

The groupWith function uses the user supplied function which projects an element out of every list element in order to first sort the input list and then to form groups by equality on these projected elements

valuesortWith :: Ord b => (a -> b) -> [a] -> [a]
#

The sortWith function sorts a list of elements using the user supplied function to project something out of each element

In general if the user supplied function is expensive to compute then you should probably be using sortOn, as it only needs to compute it once for each element. sortWith, on the other hand must compute the mapping function for every comparison that it performs.

valuefloatToDigits :: RealFloat a => Integer -> a -> ([Int], Int)
#

floatToDigits takes a base and a non-negative RealFloat number, and returns a list of digits and an exponent. In particular, if x>=0, and

floatToDigits base x = ([d1,d2,...,dn], e)

then

  1. n >= 1
  2. x = 0.d1d2...dn * (base**e)
  3. 0 <= di <= base-1
valueshowFloat :: RealFloat a => a -> ShowS
#

Show a signed RealFloat value to full precision using standard decimal notation for arguments whose absolute value lies between 0.1 and 9,999,999, and scientific notation otherwise.

valuenewForeignPtr :: FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
#

Turns a plain memory reference into a foreign pointer, and associates a finalizer with the reference. The finalizer will be executed after the last reference to the foreign object is dropped. There is no guarantee of promptness, however the finalizer will be executed before the program exits.

valuefreeHaskellFunPtr :: FunPtr a -> IO ()
#

Release the storage associated with the given FunPtr, which must have been obtained from a wrapper stub. This should be called whenever the return value from a foreign import wrapper function is no longer required; otherwise, the storage it uses will leak.

This function adds a finalizer to the given foreign object. The finalizer will run before all other finalizers for the same object which have already been registered.

valuefinalizeForeignPtr :: ForeignPtr a -> IO ()
#

Causes the finalizers associated with a foreign pointer to be run immediately. The foreign pointer must not be used again after this function is called. If the foreign pointer does not support finalizers, this is a no-op.

valuemallocForeignPtr :: Storable a => IO (ForeignPtr a)
#

Allocate some memory and return a ForeignPtr to it. The memory will be released automatically when the ForeignPtr is discarded.

mallocForeignPtr is equivalent to

   do { p <- malloc; newForeignPtr finalizerFree p }

although it may be implemented differently internally: you may not assume that the memory returned by mallocForeignPtr has been allocated with malloc.

GHC notes: mallocForeignPtr has a heavily optimised implementation in GHC. It uses pinned memory in the garbage collected heap, so the ForeignPtr does not require a finalizer to free the memory. Use of mallocForeignPtr and associated functions is strongly recommended in preference to newForeignPtr with a finalizer.

valueplusForeignPtr :: ForeignPtr a -> Int -> ForeignPtr b
#

Advances the given address by the given offset in bytes.

The new ForeignPtr shares the finalizer of the original, equivalent from a finalization standpoint to just creating another reference to the original. That is, the finalizer will not be called before the new ForeignPtr is unreachable, nor will it be called an additional time due to this call, and the finalizer will be called with the same address that it would have had this call not happened, *not* the new address.

valuetouchForeignPtr :: ForeignPtr a -> IO ()
#

This function ensures that the foreign object in question is alive at the given place in the sequence of IO actions. However, this comes with a significant caveat: the contract above does not hold if GHC can demonstrate that the code preceding touchForeignPtr diverges (e.g. by looping infinitely or throwing an exception). For this reason, you are strongly advised to use instead withForeignPtr where possible.

Also, note that this function should not be used to express dependencies between finalizers on ForeignPtrs. For example, if the finalizer for a ForeignPtr F1 calls touchForeignPtr on a second ForeignPtr F2, then the only guarantee is that the finalizer for F2 is never started before the finalizer for F1. They might be started together if for example both F1 and F2 are otherwise unreachable, and in that case the scheduler might end up running the finalizer for F2 first.

In general, it is not recommended to use finalizers on separate objects with ordering constraints between them. To express the ordering robustly requires explicit synchronisation using MVars between the finalizers, but even then the runtime sometimes runs multiple finalizers sequentially in a single thread (for performance reasons), so synchronisation between finalizers could result in artificial deadlock. Another alternative is to use explicit reference counting.

valuewithForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b
#

This is a way to look at the pointer living inside a foreign object. This function takes a function which is applied to that pointer. The resulting IO action is then executed. The foreign object is kept alive at least during the whole action, even if it is not used directly inside. Note that it is not safe to return the pointer from the action and use it after the action completes. All uses of the pointer should be inside the withForeignPtr bracket. The reason for this unsafeness is the same as for unsafeForeignPtrToPtr below: the finalizer may run earlier than expected, because the compiler can only track usage of the ForeignPtr object, not a Ptr object made from it.

This function is normally used for marshalling data to or from the object pointed to by the ForeignPtr, using the operations from the Storable class.

valuecatch
  1. :: Exception e
  2. => IO a

    The computation to run

  3. -> (e -> IO a)

    Handler to invoke if an exception is raised

  4. -> IO a
#

This is the simplest of the exception-catching functions. It takes a single argument, runs it, and if an exception is raised the "handler" is executed, with the value of the exception passed as an argument. Otherwise, the result is returned as normal. For example:

  catch (readFile f)
        (\e -> do let err = show (e :: IOException)
                  hPutStr stderr ("Warning: Couldn't open " ++ f ++ ": " ++ err)
                  return "")

Note that we have to give a type signature to e, or the program will not typecheck as the type is ambiguous. While it is possible to catch exceptions of any type, see the section "Catching all exceptions" (in Control.Exception) for an explanation of the problems with doing so.

For catching exceptions in pure (non-IO) expressions, see the function evaluate.

Note that due to Haskell's unspecified evaluation order, an expression may throw one of several possible exceptions: consider the expression (error "urk") + (1 `div` 0). Does the expression throw ErrorCall "urk", or DivideByZero?

The answer is "it might throw either"; the choice is non-deterministic. If you are catching any type of exception then you might catch either. If you are calling catch with type IO Int -> (ArithException -> IO Int) -> IO Int then the handler may get run with DivideByZero as an argument, or an ErrorCall "urk" exception may be propagated further up. If you call it again, you might get the opposite behaviour. This is ok, because catch is an IO computation.

valueevaluate :: a -> IO a
#

Evaluate the argument to weak head normal form.

evaluate is typically used to uncover any exceptions that a lazy value may contain, and possibly handle them.

evaluate only evaluates to weak head normal form. If deeper evaluation is needed, the force function from Control.DeepSeq may be handy:

evaluate $ force x

There is a subtle difference between evaluate x and return $! x, analogous to the difference between throwIO and throw. If the lazy value x throws an exception, return $! x will fail to return an IO action and will throw an exception instead. evaluate x, on the other hand, always produces an IO action; that action will throw an exception upon execution iff x throws an exception upon evaluation.

The practical implication of this difference is that due to the imprecise exceptions semantics,

(return $! error "foo") >> error "bar"

may throw either "foo" or "bar", depending on the optimizations performed by the compiler. On the other hand,

evaluate (error "foo") >> error "bar"

is guaranteed to throw "foo".

The rule of thumb is to use evaluate to force or handle exceptions in lazy values. If, on the other hand, you are forcing a lazy value for efficiency reasons only and do not care about exceptions, you may use return $! x.

valuemask :: ((forall a. IO a -> IO a) -> IO b) -> IO b
#

Executes an IO computation with asynchronous exceptions masked. That is, any thread which attempts to raise an exception in the current thread with throwTo will be blocked until asynchronous exceptions are unmasked again.

The argument passed to mask is a function that takes as its argument another function, which can be used to restore the prevailing masking state within the context of the masked computation. For example, a common way to use mask is to protect the acquisition of a resource:

mask $ \restore -> do
    x <- acquire
    restore (do_something_with x) `onException` release
    release

This code guarantees that acquire is paired with release, by masking asynchronous exceptions for the critical parts. (Rather than write this code yourself, it would be better to use bracket which abstracts the general pattern).

Note that the restore action passed to the argument to mask does not necessarily unmask asynchronous exceptions, it just restores the masking state to that of the enclosing context. Thus if asynchronous exceptions are already masked, mask cannot be used to unmask exceptions again. This is so that if you call a library function with exceptions masked, you can be sure that the library call will not be able to unmask exceptions again. If you are writing library code and need to use asynchronous exceptions, the only way is to create a new thread; see forkIOWithUnmask.

Asynchronous exceptions may still be received while in the masked state if the masked thread blocks in certain ways; see Control.Exception#interruptible.

Threads created by forkIO inherit the MaskingState from the parent; that is, to start a thread in the MaskedInterruptible state, use mask_ $ forkIO .... This is particularly useful if you need to establish an exception handler in the forked thread before any asynchronous exceptions are received. To create a new thread in an unmasked state use forkIOWithUnmask.

valuemask_ :: IO a -> IO a
#

Like mask, but does not pass a restore action to the argument.

valuestToIO :: ST RealWorld a -> IO a
#

Embed a strict state thread in an IO action. The RealWorld parameter indicates that the internal state used by the ST computation is a special one supplied by the IO monad, and thus distinct from those used by invocations of runST.

valuethrowIO :: (HasCallStack, Exception e) => e -> IO a
#

A variant of throw that can only be used within the IO monad.

Although throwIO has a type that is an instance of the type of throw, the two functions are subtly different:

throw e   `seq` ()  ===> throw e
throwIO e `seq` ()  ===> ()

The first example will cause the exception e to be raised, whereas the second one won't. In fact, throwIO will only cause an exception to be raised when it is used within the IO monad.

The throwIO variant should be used in preference to throw to raise an exception within the IO monad because it guarantees ordering with respect to other operations, whereas throw does not. We say that throwIO throws *precise* exceptions and throw, error, etc. all throw *imprecise* exceptions. For example

throw e + error "boom" ===> error "boom"
throw e + error "boom" ===> throw e

are both valid reductions and the compiler may pick any (loop, even), whereas

throwIO e >> error "boom" ===> throwIO e

will always throw e when executed.

See also the GHC wiki page on precise exceptions for a more technical introduction to how GHC optimises around precise vs. imprecise exceptions.

valueuninterruptibleMask :: ((forall a. IO a -> IO a) -> IO b) -> IO b
#

Like mask, but the masked computation is not interruptible (see Control.Exception#interruptible). THIS SHOULD BE USED WITH GREAT CARE, because if a thread executing in uninterruptibleMask blocks for any reason, then the thread (and possibly the program, if this is the main thread) will be unresponsive and unkillable. This function should only be necessary if you need to mask exceptions around an interruptible operation, and you can guarantee that the interruptible operation will only block for a short period of time.

valueuserError :: String -> IOError
#

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

instance Monad IO where
  ...
  fail s = ioError (userError s)
valuehClose :: Handle -> IO ()
#

Computation hClose hdl makes handle hdl closed. Before the computation finishes, if hdl is writable its buffer is flushed as for hFlush. Performing hClose on a handle that has already been closed has no effect; doing so is not an error. All other operations on a closed handle will fail. If hClose fails for any reason, any further operations (apart from hClose) on the handle will still fail as if hdl had been successfully closed.

hClose is an interruptible operation in the sense described in Control.Exception. If hClose is interrupted by an asynchronous exception in the process of flushing its buffers, then the I/O device (e.g., file) will be closed anyway.

valueunsafeDupablePerformIO :: IO a -> a
#

This version of unsafePerformIO is more efficient because it omits the check that the IO is only being performed by a single thread. Hence, when you use unsafeDupablePerformIO, there is a possibility that the IO action may be performed multiple times (on a multiprocessor), and you should therefore ensure that it gives the same results each time. It may even happen that one of the duplicated IO actions is only run partially, and then interrupted in the middle without an exception being raised. Therefore, functions like bracket cannot be used safely within unsafeDupablePerformIO.

valueunsafeInterleaveIO :: IO a -> IO a
#

unsafeInterleaveIO allows an IO computation to be deferred lazily. When passed a value of type IO a, the IO will only be performed when the value of the a is demanded. This is used to implement lazy file reading, see GHC.Internal.System.IO.hGetContents.

valueunsafePerformIO :: IO a -> a
#

This is the "back door" into the IO monad, allowing IO computation to be performed at any time. For this to be safe, the IO computation should be free of side effects and independent of its environment.

If the I/O computation wrapped in unsafePerformIO performs side effects, then the relative order in which those side effects take place (relative to the main I/O trunk, or other calls to unsafePerformIO) is indeterminate. Furthermore, when using unsafePerformIO to cause side-effects, you should take the following precautions to ensure the side effects are performed as many times as you expect them to be. Note that these precautions are necessary for GHC, but may not be sufficient, and other compilers may require different precautions:

  • Use {-# NOINLINE foo #-} as a pragma on any function foo that calls unsafePerformIO. If the call is inlined, the I/O may be performed more than once.

  • Use the compiler flag -fno-cse to prevent common sub-expression elimination being performed on the module, which might combine two side effects that were meant to be separate. A good example is using multiple global variables (like test in the example below).

  • Make sure that the either you switch off let-floating (-fno-full-laziness), or that the call to unsafePerformIO cannot float outside a lambda. For example, if you say: f x = unsafePerformIO (newIORef []) you may get only one reference cell shared between all calls to f. Better would be f x = unsafePerformIO (newIORef [x]) because now it can't float outside the lambda.

It is less well known that unsafePerformIO is not type safe. For example:

    test :: IORef [a]
    test = unsafePerformIO $ newIORef []

    main = do
            writeIORef test [42]
            bang <- readIORef test
            print (bang :: [Char])

This program will core dump. This problem with polymorphic references is well known in the ML community, and does not arise with normal monadic use of references. There is no easy way to make it impossible once you use unsafePerformIO. Indeed, it is possible to write coerce :: a -> b with the help of unsafePerformIO. So be careful!

WARNING: If you're looking for "a way to get a String from an 'IO String'", then unsafePerformIO is not the way to go. Learn about do-notation and the <- syntax element before you proceed.

valueatomicModifyIORef' :: IORef a -> (a -> (a, b)) -> IO b
#

A strict version of atomicModifyIORef. This forces both the value stored in the IORef and the value returned.

Conceptually,

atomicModifyIORef' ref f = do
  -- Begin atomic block
  old <- readIORef ref
  let r = f old
      new = fst r
  writeIORef ref new
  -- End atomic block
  case r of
    (!_new, !res) -> pure res

The actions in the "atomic block" are not subject to interference by other threads. In particular, the value in the IORef cannot change between the readIORef and writeIORef invocations.

The new value is installed in the IORef before either value is forced. So

atomicModifyIORef' ref (x -> (x+1, undefined))

will increment the IORef and then throw an exception in the calling thread.

atomicModifyIORef' ref (x -> (undefined, x))

and

atomicModifyIORef' ref (_ -> undefined)

will each raise an exception in the calling thread, but will also install the bottoming value in the IORef, where it may be read by other threads.

This function imposes a memory barrier, preventing reordering around the "atomic block"; see Data.IORef#memmodel for details.

valuereadIORef :: IORef a -> IO a
#

Read the value of an IORef.

Beware that the CPU executing a thread can reorder reads or writes to independent locations. See Data.IORef#memmodel for more details.

valuewriteIORef :: IORef a -> a -> IO ()
#

Write a new value into an IORef.

This function does not create a memory barrier and can be reordered with other independent reads and writes within a thread, which may cause issues for multithreaded execution. In these cases, consider using atomicWriteIORef instead. See Data.IORef#memmodel for more details.

value(!!) :: HasCallStack => [a] -> Int -> a
#

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

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

WARNING: This function takes linear time in the index.

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

List index (subscript) operator, starting from 0. Returns Nothing if the index is out of bounds

This is the total variant of the partial !! operator.

WARNING: This function takes linear time in the index.

Examples
Example1 expression
['a', 'b', 'c'] !? 0Just 'a'
Example1 expression
['a', 'b', 'c'] !? 2Just 'c'
Example1 expression
['a', 'b', 'c'] !? 3Nothing
Example1 expression
['a', 'b', 'c'] !? (-1)Nothing
valuebreak :: (a -> Bool) -> [a] -> ([a], [a])
#

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

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

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

break produces the first component of the tuple lazily:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

iterate id == repeat:

Example1 expression
take 10 $ iterate id 1[1,1,1,1,1,1,1,1,1,1]
valueiterate' :: (a -> a) -> a -> [a]
#

iterate' is the strict version of iterate.

It forces the result of each application of the function to weak head normal form (WHNF) before proceeding.

Example1 expression
take 1 $ iterate' undefined 42*** Exception: Prelude.undefined
valuelast :: HasCallStack => [a] -> a
#

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

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

Examples
Example1 expression
last [1, 2, 3]3
Example1 expression
last [1..]* Hangs forever *
Example1 expression
last []*** Exception: Prelude.last: empty list
valuelookup :: Eq a => a -> [(a, b)] -> Maybe b
#

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

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

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

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

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

Examples
Example1 expression
replicate 0 True[]
Example1 expression
replicate (-1) True[]
Example1 expression
replicate 4 True[True,True,True,True]
valuereverse :: [a] -> [a]
#

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

Laziness

reverse is lazy in its elements.

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

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

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

Note that

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

\mathcal{O}(n). A strict version of scanl.

valuescanl1 :: (a -> a -> a) -> [a] -> [a]
#

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

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

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

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

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

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

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

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

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

span produces the first component of the tuple lazily:

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

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

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

Laziness

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

The first component of the tuple is produced lazily:

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

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

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

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

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

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

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

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

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

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

\mathcal{O}(1). Decompose a list into its head and tail.

  • If the list is empty, returns Nothing.

  • If the list is non-empty, returns Just (x, xs), where x is the head of the list and xs its tail.

Examples
Example1 expression
uncons []Nothing
Example1 expression
uncons [1]Just (1,[])
Example1 expression
uncons [1, 2, 3]Just (1,[2,3])
valueunsnoc :: [a] -> Maybe ([a], a)
#

\mathcal{O}(n). Decompose a list into init and last.

  • If the list is empty, returns Nothing.

  • If the list is non-empty, returns Just (xs, x), where xs is the initial part of the list and x is its last element.

unsnoc is dual to uncons: for a finite list xs

unsnoc xs = (\(hd, tl) -> (reverse tl, hd)) <$> uncons (reverse xs)
Examples
Example1 expression
unsnoc []Nothing
Example1 expression
unsnoc [1]Just ([],1)
Example1 expression
unsnoc [1, 2, 3]Just ([1,2],3)
Laziness
Example1 expression
fst <$> unsnoc [undefined]Just []
Example1 expression
head . fst <$> unsnoc (1 : undefined)Just *** Exception: Prelude.undefined
Example1 expression
head . fst <$> unsnoc (1 : 2 : undefined)Just 1
valueunzip :: [(a, b)] -> ([a], [b])
#

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

Examples
Example1 expression
unzip []([],[])
Example1 expression
unzip [(1, 'a'), (2, 'b')]([1,2],"ab")
valueunzip3 :: [(a, b, c)] -> ([a], [b], [c])
#

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

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

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

valuezipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
#

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

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

zipWith is right-lazy:

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

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

Examples

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

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

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

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

Check whether a given MVar is empty.

Notice that the boolean value returned is just a snapshot of the state of the MVar. By the time you get to react on its result, the MVar may have been filled (or emptied) - so be extremely careful when using this operation. Use tryTakeMVar instead if possible.

valueputMVar :: MVar a -> a -> IO ()
#

Put a value into an MVar. If the MVar is currently full, putMVar will wait until it becomes empty.

There are two further important properties of putMVar:

  • putMVar is single-wakeup. That is, if there are multiple threads blocked in putMVar, and the MVar becomes empty, only one thread will be woken up. The runtime guarantees that the woken thread completes its putMVar operation.

  • When multiple threads are blocked on an MVar, they are woken up in FIFO order. This is useful for providing fairness properties of abstractions built using MVars.

valuereadMVar :: MVar a -> IO a
#

Atomically read the contents of an MVar. If the MVar is currently empty, readMVar will wait until it is full. readMVar is guaranteed to receive the next putMVar.

readMVar is multiple-wakeup, so when multiple readers are blocked on an MVar, all of them are woken up at the same time. The runtime guarantees that all woken threads complete their readMVar operation.

Compatibility note: Prior to base 4.7, readMVar was a combination of takeMVar and putMVar. This mean that in the presence of other threads attempting to putMVar, readMVar could block. Furthermore, readMVar would not receive the next putMVar if there was already a pending thread blocked on takeMVar. The old behavior can be recovered by implementing 'readMVar as follows:

readMVar :: MVar a -> IO a
readMVar m =
  mask_ $ do
    a <- takeMVar m
    putMVar m a
    return a
valuetakeMVar :: MVar a -> IO a
#

Return the contents of the MVar. If the MVar is currently empty, takeMVar will wait until it is full. After a takeMVar, the MVar is left empty.

There are two further important properties of takeMVar:

  • takeMVar is single-wakeup. That is, if there are multiple threads blocked in takeMVar, and the MVar becomes full, only one thread will be woken up. The runtime guarantees that the woken thread completes its takeMVar operation.

  • When multiple threads are blocked on an MVar, they are woken up in FIFO order. This is useful for providing fairness properties of abstractions built using MVars.

valuesubtract :: Num a => a -> a -> a
#

the same as flip (-).

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

valuereadBin :: (Eq a, Num a) => ReadS a
#

Read an unsigned number in binary notation.

Example1 expression
readBin "10011"[(19,"")]
valuereadDec :: (Eq a, Num a) => ReadS a
#

Read an unsigned number in decimal notation.

Example1 expression
readDec "0644"[(644,"")]
valuereadFloat :: RealFrac a => ReadS a
#

Reads an unsigned RealFrac value, expressed in decimal scientific notation.

Note that this function takes time linear in the magnitude of its input which can scale exponentially with input size (e.g. "1e100000000" is a very large number while having a very small textual form). For this reason, users should take care to avoid using this function on untrusted input. Users needing to parse floating point values (e.g. Float) are encouraged to instead use read, which does not suffer from this issue.

valuereadHex :: (Eq a, Num a) => ReadS a
#

Read an unsigned number in hexadecimal notation. Both upper or lower case letters are allowed.

Example1 expression
readHex "deadbeef"[(3735928559,"")]
valuereadInt
  1. :: Num a
  2. => a

    the base

  3. -> (Char -> Bool)

    a predicate distinguishing valid digits in this base

  4. -> (Char -> Int)

    a function converting a valid digit character to an Int

  5. -> ReadS a
#

Reads an unsigned integral value in an arbitrary base.

valuereadOct :: (Eq a, Num a) => ReadS a
#

Read an unsigned number in octal notation.

Example1 expression
readOct "0644"[(420,"")]
valueshowEFloat :: RealFloat a => Maybe Int -> a -> ShowS
#

Show a signed RealFloat value using scientific (exponential) notation (e.g. 2.45e2, 1.5e-3).

In the call showEFloat digs val, if digs is Nothing, the value is shown to full precision; if digs is Just d, then at most d digits after the decimal point are shown.

valueshowGFloat :: RealFloat a => Maybe Int -> a -> ShowS
#

Show a signed RealFloat value using standard decimal notation for arguments whose absolute value lies between 0.1 and 9,999,999, and scientific notation otherwise.

In the call showGFloat digs val, if digs is Nothing, the value is shown to full precision; if digs is Just d, then at most d digits after the decimal point are shown.

valueshowGFloatAlt :: RealFloat a => Maybe Int -> a -> ShowS
#

Show a signed RealFloat value using standard decimal notation for arguments whose absolute value lies between 0.1 and 9,999,999, and scientific notation otherwise.

This behaves as showFFloat, except that a decimal point is always guaranteed, even if not needed.

valueshowHFloat :: RealFloat a => a -> ShowS
#

Show a floating-point value in the hexadecimal format, similar to the %a specifier in C's printf.

Example3 expressions
showHFloat (212.21 :: Double) """0x1.a86b851eb851fp7"showHFloat (-12.76 :: Float) """-0x1.9851ecp3"showHFloat (-0 :: Double) """-0x0p+0"
valueshowIntAtBase :: Integral a => a -> (Int -> Char) -> a -> ShowS
#

Shows a non-negative Integral number using the base specified by the first argument, and the character representation specified by the second.

valuealignPtr :: Ptr a -> Int -> Ptr a
#

Given an arbitrary address and an alignment constraint, alignPtr yields the next higher address that fulfills the alignment constraint. An alignment constraint x is fulfilled by any address divisible by x. This operation is idempotent.

valuecastFunPtrToPtr :: FunPtr a -> Ptr b
#

Casts a FunPtr to a Ptr.

Note: this is valid only on architectures where data and function pointers range over the same set of addresses, and should only be used for bindings to external libraries whose interface already relies on this assumption.

valuecastPtrToFunPtr :: Ptr a -> FunPtr b
#

Casts a Ptr to a FunPtr.

Note: this is valid only on architectures where data and function pointers range over the same set of addresses, and should only be used for bindings to external libraries whose interface already relies on this assumption.

valueminusPtr :: Ptr a -> Ptr b -> Int
#

Computes the offset required to get from the second to the first argument. We have

p2 == p1 `plusPtr` (p2 `minusPtr` p1)
valuenullPtr :: Ptr a
#

The constant nullPtr contains a distinguished value of Ptr that is not associated with a valid memory location.

valueplusPtr :: Ptr a -> Int -> Ptr b
#

Advances the given address by the given offset in bytes.

valuelex :: ReadS String
#

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

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

  • Qualified names are not handled properly

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

  • Comments are not treated properly

valuelexLitChar :: ReadS String
#

Read a string representation of a character, using Haskell source-language escape conventions. For example:

lexLitChar  "\\nHello"  =  [("\\n", "Hello")]
valuereadLitChar :: ReadS Char
#

Read a string representation of a character, using Haskell source-language escape conventions, and convert it to the character that it encodes. For example:

readLitChar "\\nHello"  =  [('\n', "Hello")]
value(%) :: Integral a => a -> a -> Ratio a
#

Forms the ratio of two integral numbers.

value(^) :: (Num a, Integral b) => a -> b -> a
#

raise a number to a non-negative integral power

valuedenominator :: Ratio a -> a
#

Extract the denominator of the ratio in reduced form: the numerator and denominator have no common factor and the denominator is positive.

valuegcd :: Integral a => a -> a -> a
#

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

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

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

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

valuenumerator :: Ratio a -> a
#

Extract the numerator of the ratio in reduced form: the numerator and denominator have no common factor and the denominator is positive.

valueshowSigned
  1. :: Real a
  2. => (a -> ShowS)

    a function that can show unsigned values

  3. -> Int

    the precedence of the enclosing context

  4. -> a

    the value to show

  5. -> ShowS
#

Converts a possibly-negative Real value to a string.

valuerunST :: (forall s. ST s a) -> a
#

Return the value computed by a state thread. The forall ensures that the internal state used by the ST computation is inaccessible to the rest of the program.

valueintToDigit :: Int -> Char
#

Convert an Int in the range 0..15 to the corresponding single digit Char. This function fails on other inputs, and generates lower-case hexadecimal digits.

valueshowChar :: Char -> ShowS
#

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

valueshowLitChar :: Char -> ShowS
#

Convert a character to a string using only printable characters, using Haskell source-language escape conventions. For example:

showLitChar '\n' s  =  "\\n" ++ s
valuecastStablePtrToPtr :: StablePtr a -> Ptr ()
#

Coerce a stable pointer to an address. No guarantees are made about the resulting value, except that the original stable pointer can be recovered by castPtrToStablePtr. In particular, the address might not refer to an accessible memory location and any attempt to pass it to the member functions of the class Storable leads to undefined behaviour.

valuegetArgs :: IO [String]
#

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

valuegetEnvironment :: IO [(String, String)]
#

getEnvironment retrieves the entire environment as a list of (key,value) pairs.

If an environment entry does not contain an '=' character, the key is the whole entry and the value is the empty string.

valuegetProgName :: IO String
#

Computation getProgName returns the name of the program as it was invoked.

However, this is hard-to-impossible to implement on some non-Unix OSes, so instead, for maximum portability, we just return the leafname of the program as invoked. Even then there are some differences between platforms: on Windows, for example, a program invoked as foo is probably really FOO.EXE, and that is what getProgName will return.

valuelookupEnv :: String -> IO (Maybe String)
#

Return the value of the environment variable var, or Nothing if there is no such value.

For POSIX users, this is equivalent to getEnv.

valuesetEnv :: String -> String -> IO ()
#

setEnv name value sets the specified environment variable to value.

Early versions of this function operated under the mistaken belief that setting an environment variable to the empty string on Windows removes that environment variable from the environment. For the sake of compatibility, it adopted that behavior on POSIX. In particular

setEnv name ""

has the same effect as

unsetEnv name

If you'd like to be able to set environment variables to blank strings, use setEnv.

Throws IOException if name is the empty string or contains an equals sign.

Beware that this function must not be executed concurrently with getEnv, lookupEnv, getEnvironment and such. One thread reading environment variables at the same time with another one modifying them can result in a segfault, see Setenv is not Thread Safe for discussion.

valueunsetEnv :: String -> IO ()
#

unsetEnv name removes the specified environment variable from the environment of the current process.

Throws IOException if name is the empty string or contains an equals sign.

Beware that this function must not be executed concurrently with getEnv, lookupEnv, getEnvironment and such. One thread reading environment variables at the same time with another one modifying them can result in a segfault, see Setenv is not Thread Safe for discussion.

Get an action to query the absolute pathname of the current executable.

If the operating system provides a reliable way to determine the current executable, return the query action, otherwise return Nothing. The action is defined on FreeBSD, Linux, MacOS, NetBSD, Solaris, and Windows.

Even where the query action is defined, there may be situations where no result is available, e.g. if the executable file was deleted while the program is running. Therefore the result of the query action is a Maybe FilePath.

Note that for scripts and interactive sessions, the result is the path to the interpreter (e.g. ghci.)

Note also that while most operating systems return Nothing if the executable file was deleted/unlinked, some (including NetBSD) return the original path.

Returns the absolute pathname of the current executable, or argv[0] if the operating system does not provide a reliable way query the current executable.

Note that for scripts and interactive sessions, this is the path to the interpreter (e.g. ghci.)

Since base 4.11.0.0, getExecutablePath resolves symlinks on Windows. If an executable is launched through a symlink, getExecutablePath returns the absolute path of the original executable.

If the executable has been deleted, behaviour is ill-defined and varies by operating system. See executablePath for a more reliable way to query the current executable.

valueexitWith :: ExitCode -> IO a
#

Computation exitWith code throws ExitCode code. Normally this terminates the program, returning code to the program's caller.

On program termination, the standard Handles stdout and stderr are flushed automatically; any other buffered Handles need to be flushed manually, otherwise the buffered data will be discarded.

A program that fails in any other way is treated as if it had called exitFailure. A program that terminates successfully without calling exitWith explicitly is treated as if it had called exitWith ExitSuccess.

As an ExitCode is an Exception, it can be caught using the functions of Control.Exception. This means that cleanup computations added with bracket (from Control.Exception) are also executed properly on exitWith.

Note: in GHC, exitWith should be called from the main program thread in order to exit the process. When called from another thread, exitWith will throw an ExitCode as normal, but the exception will not cause the process itself to exit.

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

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

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

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

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

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

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

I/O error where the operation failed because one of its arguments is a single-use resource, which is already being used.

valuecatchIOError :: IO a -> (IOError -> IO a) -> IO a
#

The catchIOError function establishes a handler that receives any IOError raised in the action protected by catchIOError. An IOError is caught by the most recent handler established by one of the exception handling functions. These handlers are not selective: all IOErrors are caught. Exception propagation must be explicitly provided in a handler by re-raising any unwanted exceptions. For example, in

f = catchIOError g (\e -> if IO.isEOFError e then return [] else ioError e)

the function f returns [] when an end-of-file exception (cf. isEOFError) occurs in g; otherwise, the exception is propagated to the next outer handler.

When an exception propagates outside the main program, the Haskell system prints the associated IOError value and exits the program.

Non-I/O exceptions are not caught by this variant; to catch all exceptions, use catch from Control.Exception.

An error indicating that an IO operation failed because one of its arguments is a single-use resource, which is already being used (for example, opening the same file twice for writing might give this error).

valueisEOFError :: IOError -> Bool
#

An error indicating that an IO operation failed because the end of file has been reached.

An error indicating that an IO operation failed because the operation was not possible. Any computation which returns an IO result may fail with isIllegalOperation. In some cases, an implementation will not be able to distinguish between the possible error causes. In this case it should fail with isIllegalOperation.

An error indicating that an IO operation failed because the user does not have sufficient operating system privilege to perform that operation.

I/O error where the operation failed because the user does not have sufficient operating system privilege to perform that operation.

I/O error where the operation failed because the user does not have sufficient operating system privilege to perform that operation.

I/O error where the operation failed because the resource vanished. This happens when, for example, attempting to write to a closed socket or attempting to write to a named pipe that was deleted.

valueperformBlockingMajorGC :: IO ()
#

Triggers an immediate major garbage collection, ensuring that collection finishes before returning.

valueperformGC :: IO ()
#

Triggers an immediate major garbage collection.

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

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

Example1 expression
read "123" :: Int123
Example1 expression
read "hello" :: Int*** Exception: Prelude.read: no parse
valuereadEither :: Read a => String -> Either String a
#

Parse a string using the Read instance. Succeeds if there is exactly one valid result. A Left value indicates a parse error.

Example1 expression
readEither "123" :: Either String IntRight 123
Example1 expression
readEither "hello" :: Either String IntLeft "Prelude.read: no parse"
valuereadMaybe :: Read a => String -> Maybe a
#

Parse a string using the Read instance. Succeeds if there is exactly one valid result.

Example1 expression
readMaybe "123" :: Maybe IntJust 123
Example1 expression
readMaybe "hello" :: Maybe IntNothing

The Unicode general category of the character. This relies on the Enum instance of GeneralCategory, which must remain in the same order as the categories are presented in the Unicode standard.

Examples

Basic usage:

Example7 expressions
generalCategory 'a'LowercaseLettergeneralCategory 'A'UppercaseLettergeneralCategory '0'DecimalNumbergeneralCategory '%'OtherPunctuationgeneralCategory '♥'OtherSymbolgeneralCategory '\31'ControlgeneralCategory ' 'Space
valueisAlpha :: Char -> Bool
#

Selects alphabetic Unicode characters (lower-case, upper-case and title-case letters, plus letters of caseless scripts and modifiers letters). This function is equivalent to isLetter.

This function returns True if its argument has one of the following GeneralCategorys, or False otherwise:

These classes are defined in the Unicode Character Database, part of the Unicode standard. The same document defines what is and is not a "Letter".

valueisAlphaNum :: Char -> Bool
#

Selects alphabetic or numeric Unicode characters.

Note that numeric digits outside the ASCII range, as well as numeric characters which aren't digits, are selected by this function but not by isDigit. Such characters may be part of identifiers but are not used by the printer and reader to represent numbers, e.g., Roman numerals like V, full-width digits like '1' (aka '65297').

This function returns True if its argument has one of the following GeneralCategorys, or False otherwise:

valueisAscii :: Char -> Bool
#

Selects the first 128 characters of the Unicode character set, corresponding to the ASCII character set.

valueisControl :: Char -> Bool
#

Selects control characters, which are the non-printing characters of the Latin-1 subset of Unicode.

valueisHexDigit :: Char -> Bool
#

Selects ASCII hexadecimal digits, i.e. '0'..'9', 'a'..'f', 'A'..'F'.

valueisLatin1 :: Char -> Bool
#

Selects the first 256 characters of the Unicode character set, corresponding to the ISO 8859-1 (Latin-1) character set.

valueisLower :: Char -> Bool
#

Selects lower-case alphabetic Unicode characters (letters).

Note: this predicate does not work for letter-like characters such as: 'ⓐ' (U+24D0 circled Latin small letter a) and 'ⅳ' (U+2173 small Roman numeral four). This is due to selecting only characters with the GeneralCategory LowercaseLetter.

See isLowerCase for a more intuitive predicate.

valueisLowerCase :: Char -> Bool
#

Selects lower-case Unicode letter-like characters.

Note: this predicate selects characters with the Unicode property Lowercase, which includes letter-like characters such as: 'ⓐ' (U+24D0 circled Latin small letter a) and 'ⅳ' (U+2173 small Roman numeral four).

See isLower for the legacy predicate.

valueisPunctuation :: Char -> Bool
#

Selects Unicode punctuation characters, including various kinds of connectors, brackets and quotes.

This function returns True if its argument has one of the following GeneralCategorys, or False otherwise:

These classes are defined in the Unicode Character Database, part of the Unicode standard. The same document defines what is and is not a "Punctuation".

Examples

Basic usage:

Example6 expressions
isPunctuation 'a'FalseisPunctuation '7'FalseisPunctuation '♥'FalseisPunctuation '"'TrueisPunctuation '?'TrueisPunctuation '—'True
valueisSpace :: Char -> Bool
#

Returns True for any Unicode space character, and the control characters \t, \n, \r, \f, \v.

valueisSymbol :: Char -> Bool
#

Selects Unicode symbol characters, including mathematical and currency symbols.

This function returns True if its argument has one of the following GeneralCategorys, or False otherwise:

These classes are defined in the Unicode Character Database, part of the Unicode standard. The same document defines what is and is not a "Symbol".

Examples

Basic usage:

Example3 expressions
isSymbol 'a'FalseisSymbol '6'FalseisSymbol '='True

The definition of "math symbol" may be a little counter-intuitive depending on one's background:

Example2 expressions
isSymbol '+'TrueisSymbol '-'False
valueisUpper :: Char -> Bool
#

Selects upper-case or title-case alphabetic Unicode characters (letters). Title case is used by a small number of letter ligatures like the single-character form of Lj.

Note: this predicate does not work for letter-like characters such as: 'Ⓐ' (U+24B6 circled Latin capital letter A) and 'Ⅳ' (U+2163 Roman numeral four). This is due to selecting only characters with the GeneralCategory UppercaseLetter or TitlecaseLetter.

See isUpperCase for a more intuitive predicate. Note that unlike isUpperCase, isUpper does select title-case characters such as 'Dž' (U+01C5 Latin capital letter d with small letter z with caron) or 'ᾯ' (U+1FAF Greek capital letter omega with dasia and perispomeni and prosgegrammeni).

valueisUpperCase :: Char -> Bool
#

Selects upper-case Unicode letter-like characters.

Note: this predicate selects characters with the Unicode property Uppercase, which include letter-like characters such as: 'Ⓐ' (U+24B6 circled Latin capital letter A) and 'Ⅳ' (U+2163 Roman numeral four).

See isUpper for the legacy predicate. Note that unlike isUpperCase, isUpper does select title-case characters such as 'Dž' (U+01C5 Latin capital letter d with small letter z with caron) or 'ᾯ' (U+1FAF Greek capital letter omega with dasia and perispomeni and prosgegrammeni).

valuetoLower :: Char -> Char
#

Convert a letter to the corresponding lower-case letter, if any. Any other character is returned unchanged.

valuetoTitle :: Char -> Char
#

Convert a letter to the corresponding title-case or upper-case letter, if any. (Title case differs from upper case only for a small number of ligature letters.) Any other character is returned unchanged.

valuetoUpper :: Char -> Char
#

Convert a letter to the corresponding upper-case letter, if any. Any other character is returned unchanged.

valueunsafeCoerce :: a -> b
#

unsafeCoerce coerces a value from one type to another, bypassing the type-checker.

There are several legitimate ways to use unsafeCoerce:

  1. To coerce a lifted type such as Int to Any, put it in a list of Any, and then later coerce it back to Int before using it.

  2. To produce e.g. (a+b) :~: (b+a) from unsafeCoerce Refl. Here the two sides really are the same type -- so nothing unsafe is happening -- but GHC is not clever enough to see it.

  3. In Data.Typeable we have

       eqTypeRep :: forall k1 k2 (a :: k1) (b :: k2).
                    TypeRep a -> TypeRep b -> Maybe (a :~~: b)
       eqTypeRep a b
         | sameTypeRep a b = Just (unsafeCoerce HRefl)
         | otherwise       = Nothing
     

Here again, the unsafeCoerce HRefl is safe, because the two types really are the same -- but the proof of that relies on the complex, trusted implementation of Typeable.

  1. (superseded) The "reflection trick", which takes advantage of the fact that in class C a where { op :: ty }, we can safely coerce between C a and ty (which have different kinds!) because it's really just a newtype. Note: there is no guarantee, at all that this behavior will be supported into perpetuity. It is now preferred to use withDict in GHC.Magic.Dict, which is type-safe. See Note [withDict] in GHC.Tc.Instance.Class for details.

  2. (superseded) Casting between two types which have exactly the same structure: between a newtype of T and T, or between types which differ only in "phantom" type parameters. It is now preferred to use coerce from Data.Coerce, which is type-safe.

Other uses of unsafeCoerce are undefined. In particular, you should not use unsafeCoerce to cast a T to an algebraic data type D, unless T is also an algebraic data type. For example, do not cast Int->Int to Bool, even if you later cast that Bool back to Int->Int before applying it. The reasons have to do with GHC's internal representation details (for the cognoscenti, data values can be entered but function closures cannot). If you want a safe type to cast things to, use Any, which is not an algebraic data type.

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

Boolean "and", lazy in the second argument

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

Boolean "or", lazy in the second argument

valuegetSolo :: (a) -> a
#

Extract the value from a Solo. Very often, values should be extracted directly using pattern matching, to control just what gets evaluated when. getSolo is for convenience in situations where that is not the case:

When the result is passed to a strict function, it makes no difference whether the pattern matching is done on the "outside" or on the "inside":

Data.Set.insert (getSolo sol) set === case sol of Solo v -> Data.Set.insert v set

A traversal may be performed in Solo in order to control evaluation internally, while using getSolo to extract the final result. A strict mapping function, for example, could be defined

map' :: Traversable t => (a -> b) -> t a -> t b
map' f = getSolo . traverse ((Solo $!) . f)
valuegenerated' :: (Eq a, Cyclic a) => [a]
#

Lazily generate all elements of a Cyclic group using its generator.

Note: Fuses, terminates if the underlying group is finite.

valuedefaultHashWithSalt :: Hashable a => Int -> a -> Int
#

Since we support a generic implementation of hashWithSalt we cannot also provide a default implementation for that method for the non-generic instance use case. Instead we provide defaultHashWith.

valuehashByteArray
  1. :: ByteArray#

    data to hash

  2. -> Int

    offset, in bytes

  3. -> Int

    length, in bytes

  4. -> Int

    hash value

#

Compute a hash value for the content of this ByteArray#, beginning at the specified offset, using specified number of bytes.

valuehashPtr
  1. :: Ptr a

    pointer to the data to hash

  2. -> Int

    length, in bytes

  3. -> IO Int

    hash value

#

Compute a hash value for the content of this pointer.

valuehashUsing
  1. :: Hashable b
  2. => (a -> b)

    Transformation function.

  3. -> Int

    Salt.

  4. -> a

    Value to transform.

  5. -> Int
#

Transform a value into a Hashable value, then hash the transformed value using the given salt.

This is a useful shorthand in cases where a type can easily be mapped to another type that is already an instance of Hashable. Example:

data Foo = Foo | Bar
         deriving (Enum)

instance Hashable Foo where
    hashWithSalt = hashUsing fromEnum
valuehashByteArrayWithSalt
  1. :: ByteArray#

    data to hash

  2. -> Int

    offset, in bytes

  3. -> Int

    length, in bytes

  4. -> Salt

    salt

  5. -> Salt

    hash value

#

Compute a hash value for the content of this ByteArray#, using an initial salt.

This function can for example be used to hash non-contiguous segments of memory as if they were one contiguous segment, by using the output of one hash as the salt for the next.

valuehashPtrWithSalt
  1. :: Ptr a

    pointer to the data to hash

  2. -> Int

    length, in bytes

  3. -> Salt

    salt

  4. -> IO Salt

    hash value

#

Compute a hash value for the content of this pointer, using an initial salt.

This function can for example be used to hash non-contiguous segments of memory as if they were one contiguous segment, by using the output of one hash as the salt for the next.

valueinvmapArrow :: Arrow arr => (a -> b) -> (b -> a) -> arr a a -> arr b b
#

An Arrow with the same input and output types can be seen as an Invariant functor.

valueliftCallCC
  1. :: (MonadTrans t, Monad m, forall (m' :: Type -> Type). Monad m' => Monad (t m'))
  2. => CallCC m (t m a) b
  3. -> CallCC (t m) a b
#

Lift a callCC-style function through any MonadTrans.

Note

For any function f, 'liftCallCC f' satisfies the uniformity condition provided that f is quasi-algebraic. More specifically, for any g, we must have:

'join' '$' f (\exit -> 'pure' '$' g (exit '.' 'pure') = f g

callCC is quasi-algebraic; furthermore, for any quasi-algebraic f, liftCallCC f is also quasi-algebraic.

See also

valuemodifyError :: MonadError e' m => (e -> e') -> ExceptT e m a -> m a
#

A different MonadError analogue to the withExceptT function. Modify the value (and possibly the type) of an error in an ExceptT-transformed monad, while stripping the ExceptT layer.

This is useful for adapting the MonadError constraint of a computation.

For example:

data DatabaseError = ...

performDatabaseQuery :: (MonadError DatabaseError m, ...) => m PersistedValue

data AppError
  = MkDatabaseError DatabaseError
  | ...

app :: (MonadError AppError m, ...) => m ()

Given these types, performDatabaseQuery cannot be used directly inside app, because the error types don't match. Using modifyError, an equivalent function with a different error type can be constructed:

performDatabaseQuery' :: (MonadError AppError m, ...) => m PersistedValue
performDatabaseQuery' = modifyError MkDatabaseError performDatabaseQuery

Since the error types do match, performDatabaseQuery' _can_ be used in app, assuming all other constraints carry over.

This works by instantiating the m in the type of performDatabaseQuery to ExceptT DatabaseError m', which satisfies the MonadError DatabaseError constraint. Immediately, the ExceptT DatabaseError layer is unwrapped, producing Either a DatabaseError or a PersistedValue. If it's the former, the error is wrapped in MkDatabaseError and re-thrown in the inner monad, otherwise the result value is returned.

valuewithError :: MonadError e m => (e -> e) -> m a -> m a
#

MonadError analogue to the withExceptT function. Modify the value (but not the type) of an error. The type is fixed because of the functional dependency m -> e. If you need to change the type of e use mapError or modifyError.

valueasks
  1. :: MonadReader r m
  2. => (r -> a)

    The selector function to apply to the environment.

  3. -> m a
#

Retrieves a function of the current environment.

valuegets :: MonadState s m => (s -> a) -> m a
#

Gets specific component of the state, using a projection function supplied.

valuemodify :: MonadState s m => (s -> s) -> m ()
#

Monadic state transformer.

Maps an old state to a new state inside a state monad. The old state is thrown away.

     Main> :t modify ((+1) :: Int -> Int)
     modify (...) :: (MonadState Int a) => a ()

This says that modify (+1) acts over any Monad that is a member of the MonadState class, with an Int state.

valuemodify' :: MonadState s m => (s -> s) -> m ()
#

A variant of modify in which the computation is strict in the new state.

valuecensor :: MonadWriter w m => (w -> w) -> m a -> m a
#

censor f m is an action that executes the action m and applies the function f to its output, leaving the return value unchanged.

valuelistens :: MonadWriter w m => (w -> b) -> m a -> m (a, b)
#

listens f m is an action that executes the action m and adds the result of applying f to the output to the value of the computation.

valuedecomposeRan :: Procompose (Ran q p) q a b -> p a b
#

The 2-morphism that defines a right Kan extension.

Note: When q is left adjoint to Ran q (->) then decomposeRan is the counit of the adjunction.

valuecoprepAdj :: (forall (a :: k). f a -> Coprep p a) -> p :-> Costar f
#
Coprep -| Costar :: [Hask, Hask]^op -> Prof

Like all adjunctions this gives rise to a monad and a comonad.

This gives rise to a monad on Prof (Costar.Coprep) and a comonad on [Hask, Hask]^op given by (Coprep.Costar) which is a monad in [Hask,Hask]

value(<*?) :: Selective f => f (Either a b) -> f (a -> b) -> f b
#

An operator alias for select, which is sometimes convenient. It tries to follow the notational convention for Applicative operators. The angle bracket pointing to the left means we always use the corresponding value. The value on the right, however, may be skipped, hence the question mark.

valueallS :: Selective f => (a -> f Bool) -> [a] -> f Bool
#

A lifted version of all. Retains the short-circuiting behaviour.

valueanyS :: Selective f => (a -> f Bool) -> [a] -> f Bool
#

A lifted version of any. Retains the short-circuiting behaviour.

valueapS :: Selective f => f (a -> b) -> f a -> f b
#

Recover the application operator <*> from select. Rigid selective functors satisfy the law <*> = apS and furthermore, the resulting applicative functor satisfies all laws of Applicative:

  • Identity:

    pure id <*> v = v
  • Homomorphism:

    pure f <*> pure x = pure (f x)
  • Interchange:

    u <*> pure y = pure ($y) <*> u
  • Composition:

    (.) <$> u <*> v <*> w = u <*> (v <*> w)
valuebindS :: (Bounded a, Enum a, Eq a, Selective f) => f a -> (a -> f b) -> f b
#

A restricted version of monadic bind. Fails with an error if the Bounded and Enum instances for a do not cover all values of a.

valuebranch :: Selective f => f (Either a b) -> f (a -> c) -> f (b -> c) -> f c
#

The branch function is a natural generalisation of select: instead of skipping an unnecessary effect, it chooses which of the two given effectful functions to apply to a given argument; the other effect is unnecessary. It is possible to implement branch in terms of select, which is a good puzzle (give it a try!).

We can also implement select via branch:

selectB :: Selective f => f (Either a b) -> f (a -> b) -> f b
selectB x y = branch x y (pure id)
valueifS :: Selective f => f Bool -> f a -> f a -> f a
#

Branch on a Boolean value, skipping unnecessary effects.

valuematchM :: Monad m => Cases a -> m a -> (a -> m b) -> m (Either a b)
#

Eliminate all specified values a from f (Either a b) by replacing each of them with a given f a.

valuematchS
  1. :: (Eq a, Selective f)
  2. => Cases a
  3. -> f a
  4. -> a -> f b
  5. -> f (Either a b)
#

Eliminate all specified values a from f (Either a b) by replacing each of them with a given f a.

valueselectA :: Applicative f => f (Either a b) -> f (a -> b) -> f b
#

We can write a function with the type signature of select using the Applicative type class, but it will always execute the effects associated with the second argument, hence being potentially less efficient.

valueselectT :: Traversable f => f (Either a b) -> f (a -> b) -> f b
#

For traversable functors, we can implement select in another interesting way: the effects associated with the second argument can be skipped as long as the first argument contains only Right values.

valueuntilRight :: (Monoid a, Selective f) => f (Either a b) -> f (a, b)
#

Keep running an effectful computation until it returns a Right value, collecting the Left's using a supplied Monoid instance.

valuewhileS :: Selective f => f Bool -> f ()
#

Keep checking an effectful condition while it holds.

value(<<..>>) :: Biapply p => p a c -> p (a -> b) (c -> d) -> p b d
#
valuebilift2
  1. :: Biapply w
  2. => a -> b -> c
  3. -> d -> e -> f
  4. -> w a d
  5. -> w b e
  6. -> w c f
#

Lift binary functions

valuebilift3
  1. :: Biapply w
  2. => a -> b -> c -> d
  3. -> e -> f -> g -> h
  4. -> w a e
  5. -> w b f
  6. -> w c g
  7. -> w d h
#

Lift ternary functions

valuegalt :: (Generic1 f, Alt (Rep1 f)) => f a -> f a -> f a
#

Generic (<!>). Caveats:

  1. Will not compile if f is a sum type.

  2. Any types where the a does not appear must have a Semigroup instance.

value(<..>) :: Apply w => w a -> w (a -> b) -> w b
#

A variant of <.> with the arguments reversed.

valuegliftF2
  1. :: (Generic1 w, Apply (Rep1 w))
  2. => a -> b -> c
  3. -> w a
  4. -> w b
  5. -> w c
#

Generic liftF2. Caveats:

  1. Will not compile if w is a sum type.

  2. Types in w that do not mention the type variable must be instances of Semigroup.

valueliftF3 :: Apply w => (a -> b -> c -> d) -> w a -> w b -> w c -> w d
#

Lift a ternary function into a comonad with zipping

value(-<-) :: Bind m => (b -> m c) -> (a -> m b) -> a -> m c
#
value(-<<) :: Bind m => (a -> m b) -> m a -> m b
#
value(->-) :: Bind m => (a -> m b) -> (b -> m c) -> a -> m c
#
valuegbind :: (Generic1 m, Bind (Rep1 m)) => m a -> (a -> m b) -> m b
#

Generic (>>-). Caveats:

  1. Will not compile if m is a sum type.

  2. Will not compile if m contains fields that do not mention its type variable.

  3. Will not compile if m contains fields where the type variable appears underneath the composition of type constructors (e.g., f (g a)).

  4. May do redundant work, due to the nature of the Bind instance for (:*:)

value(<*.>) :: Apply f => MaybeApply f (a -> b) -> f a -> f b
#

Apply a possibly-empty-with-unit container of functions to a non-empty container of values.

value(<.*>) :: Apply f => f (a -> b) -> MaybeApply f a -> f b
#

Apply a non-empty container of functions to a possibly-empty-with-unit container of values.

valuegduplicated :: (Extend (Rep1 w), Generic1 w) => w a -> w (w a)
#

Generic duplicated. Caveats:

  1. Will not compile if w is a product type.

  2. Will not compile if w contains fields where the type variable appears underneath the composition of type constructors (e.g., f (g a)).

valuegzero :: (Plus (Rep1 f), Generic1 f) => f a
#

Generic zero. Caveats:

  1. Will not compile if f is a sum type.

  2. Any types where the a does not appear must have a Monoid instance.

valuepsum :: (Foldable t, Plus f) => t (f a) -> f a
#

The sum of a collection of actions, generalizing concat.

Example1 expression
psum [Just "Hello", Nothing, Just "World"]Just "Hello"
valuegfold1 :: (Foldable1 (Rep1 t), Generic1 t, Semigroup m) => t m -> m
#

Generic fold1. Caveats:

  1. Will not compile if t is an empty constructor.

  2. Will not compile if t has some fields that don't mention a, for exmaple data Bar a = MkBar a Int

valueintercalateMap1 :: (Foldable1 t, Semigroup m) => m -> (a -> m) -> t a -> m
#

Insert m between each pair of m derived from a.

Example1 expression
intercalateMap1 " " show $ True :| [False, True]"True False True"
Example1 expression
intercalateMap1 " " show $ True :| []"True"
valuegtraverse1
  1. :: (Traversable1 (Rep1 t), Apply f, Generic1 t)
  2. => a -> f b
  3. -> t a
  4. -> f (t b)
#

Generic traverse1. Caveats:

  1. Will not compile if t is an empty constructor.

  2. Will not compile if t has some fields that don't mention a, for exmaple data Bar a = MkBar a Int

valuepeekTBQueue :: TBQueue a -> STM a
#

Get the next value from the TBQueue without removing it, retrying if the channel is empty.

valueunGetTBQueue :: TBQueue a -> a -> STM ()
#

Put a data item back onto a channel, where it will be the next item read. Blocks if the queue is full.

valuecloneTChan :: TChan a -> STM (TChan a)
#

Clone a TChan: similar to dupTChan, but the cloned channel starts with the same content available as the original channel.

valuedupTChan :: TChan a -> STM (TChan a)
#

Duplicate a TChan: the duplicate channel begins empty, but data written to either channel from then on will be available from both. Hence this creates a kind of broadcast channel, where data written by anyone is seen by everyone else.

valuenewBroadcastTChan :: STM (TChan a)
#

Create a write-only TChan. More precisely, readTChan will retry even after items have been written to the channel. The only way to read a broadcast channel is to duplicate it with dupTChan.

Consider a server that broadcasts messages to clients:

serve :: TChan Message -> Client -> IO loop
serve broadcastChan client = do
    myChan <- dupTChan broadcastChan
    forever $ do
        message <- readTChan myChan
        send client message

The problem with using newTChan to create the broadcast channel is that if it is only written to and never read, items will pile up in memory. By using newBroadcastTChan to create the broadcast channel, items can be garbage collected after clients have seen them.

valuepeekTChan :: TChan a -> STM a
#

Get the next value from the TChan without removing it, retrying if the channel is empty.

valueunGetTChan :: TChan a -> a -> STM ()
#

Put a data item back onto a channel, where it will be the next item read.

valuewriteTMVar :: TMVar a -> a -> STM ()
#

Non-blocking write of a new value to a TMVar Puts if empty. Replaces if populated.

valueflushTQueue :: TQueue a -> STM [a]
#

Efficiently read the entire contents of a TQueue into a list. This function never retries.

valuepeekTQueue :: TQueue a -> STM a
#

Get the next value from the TQueue without removing it, retrying if the channel is empty.

valueunGetTQueue :: TQueue a -> a -> STM ()
#

Put a data item back onto a channel, where it will be the next item read.

valuemodifyTVar :: TVar a -> (a -> a) -> STM ()
#

Mutate the contents of a TVar. N.B., this version is non-strict.

valuestateTVar :: TVar s -> (s -> (a, s)) -> STM a
#

Like modifyTVar' but the function is a simple state transition that can return a side value which is passed on as the result of the STM.

valuecheck :: Bool -> STM ()
#

Check that the boolean condition is true and, if not, retry.

In other words, check b = unless b retry.

valueperiodFromDay :: DayPeriod p => Day -> (p, Int)
#

Get the period this day is in, with the 1-based day number within the period.

periodFromDay (periodFirstDay p) = (p,1)
patternpattern YearMonthDay :: Year -> MonthOfYear -> DayOfMonth -> Day
#

Bidirectional abstract constructor for the proleptic Gregorian calendar. Invalid values will be clipped to the correct range, month first, then day.

Add months, with days past the last day of the month clipped to the last day. For instance, 2005-01-30 + 1 month = 2005-02-28.

Add years, matching month and day, with Feb 29th clipped to Feb 28th if necessary. For instance, 2004-02-29 + 2 years = 2006-02-28.

Add years, matching month and day, with Feb 29th rolled over to Mar 1st if necessary. For instance, 2004-02-29 + 2 years = 2006-03-01.

valueisLeapYear :: Year -> Bool
#

Is this year a leap year according to the proleptic Gregorian calendar?

valueweekAllDays :: DayOfWeek -> Day -> [Day]
#

Returns a week containing the given Day where the first day is the DayOfWeek specified.

Examples:

Example1 expression
weekAllDays Sunday (YearMonthDay 2022 02 21)[YearMonthDay 2022 2 20 .. YearMonthDay 2022 2 26]
Example1 expression
weekAllDays Monday (YearMonthDay 2022 02 21)[YearMonthDay 2022 2 21 .. YearMonthDay 2022 2 27]
Example1 expression
weekAllDays Tuesday (YearMonthDay 2022 02 21)[YearMonthDay 2022 2 15 .. YearMonthDay 2022 2 21]
valueweekFirstDay :: DayOfWeek -> Day -> Day
#

Returns the first day of a week containing the given Day.

Examples:

Example1 expression
weekFirstDay Sunday (YearMonthDay 2022 02 21)YearMonthDay 2022 2 20
Example1 expression
weekFirstDay Monday (YearMonthDay 2022 02 21)YearMonthDay 2022 2 21
Example1 expression
weekFirstDay Tuesday (YearMonthDay 2022 02 21)YearMonthDay 2022 2 15
valueweekLastDay :: DayOfWeek -> Day -> Day
#

Returns the last day of a week containing the given Day.

Examples:

Example1 expression
weekLastDay Sunday (YearMonthDay 2022 02 21)YearMonthDay 2022 2 26
Example1 expression
weekLastDay Monday (YearMonthDay 2022 02 21)YearMonthDay 2022 2 27
Example1 expression
weekLastDay Tuesday (YearMonthDay 2022 02 21)YearMonthDay 2022 2 21
valueformatTime :: FormatTime t => TimeLocale -> String -> t -> String
#

Substitute various time-related information for each %-code in the string, as per formatCharacter.

The general form is %<modifier><width><alternate><specifier>, where <modifier>, <width>, and <alternate> are optional.

<modifier>

glibc-style modifiers can be used before the specifier (here marked as z):

%-z

no padding

%_z

pad with spaces

%0z

pad with zeros

%^z

convert to upper case

%#z

convert to lower case (consistently, unlike glibc)

<width>

Width digits can also be used after any modifiers and before the specifier (here marked as z), for example:

%4z

pad to 4 characters (with default padding character)

%_12z

pad with spaces to 12 characters

<alternate>

An optional E character indicates an alternate formatting. Currently this only affects %Z and %z.

%Ez

alternate formatting

<specifier>

For all types (note these three are done by formatTime, not by formatCharacter):

%%

%

%t

tab

%n

newline

TimeZone

For TimeZone (and ZonedTime and UTCTime):

%z

timezone offset in the format

±HHMM

%Ez

timezone offset in the format

±HH:MM

%Z

timezone name (or else offset in the format

±HHMM

)

%EZ

timezone name (or else offset in the format

±HH:MM

)

LocalTime

For LocalTime (and ZonedTime and UTCTime and UniversalTime):

%c

as

dateTimeFmt

locale

(e.g.

%a %b %e %H:%M:%S %Z %Y

)

TimeOfDay

For TimeOfDay (and LocalTime and ZonedTime and UTCTime and UniversalTime):

%R

same as

%H:%M

%T

same as

%H:%M:%S

%X

as

timeFmt

locale

(e.g.

%H:%M:%S

)

%r

as

time12Fmt

locale

(e.g.

%I:%M:%S %p

)

%P

day-half of day from (

amPm

locale

), converted to lowercase,

am

,

pm

%p

day-half of day from (

amPm

locale

),

AM

,

PM

%H

hour of day (24-hour), 0-padded to two chars,

00

-

23

%k

hour of day (24-hour), space-padded to two chars,

0

-

23

%I

hour of day-half (12-hour), 0-padded to two chars,

01

-

12

%l

hour of day-half (12-hour), space-padded to two chars,

1

-

12

%M

minute of hour, 0-padded to two chars,

00

-

59

%S

second of minute (without decimal part), 0-padded to two chars,

00

-

60

%q

picosecond of second, 0-padded to twelve chars,

000000000000

-

999999999999

.

%Q

decimal point and fraction of second, up to 12 second decimals, without trailing zeros. For a whole number of seconds,

%Q

omits the decimal point unless padding is specified.

UTCTime and ZonedTime

For UTCTime and ZonedTime:

%s

number of whole seconds since the Unix epoch. For times before the Unix epoch, this is a negative number. Note that in

%s.%q

and

%s%Q

the decimals are positive, not negative. For example, 0.9 seconds before the Unix epoch is formatted as

-1.1

with

%s%Q

.

DayOfWeek

For DayOfWeek (and Day and LocalTime and ZonedTime and UTCTime and UniversalTime):

%u

day of week number for Week Date format,

1

(= Monday) -

7

(= Sunday)

%w

day of week number,

0

(= Sunday) -

6

(= Saturday)

%a

day of week, short form (

snd

from

wDays

locale

),

Sun

-

Sat

%A

day of week, long form (

fst

from

wDays

locale

),

Sunday

-

Saturday

Month

For Month (and Day and LocalTime and ZonedTime and UTCTime and UniversalTime):

%Y

year, no padding. Note

%0Y

and

%_Y

pad to four chars

%y

year of century, 0-padded to two chars,

00

-

99

%C

century, no padding. Note

%0C

and

%_C

pad to two chars

%B

month name, long form (

fst

from

months

locale

),

January

-

December

%b, %h

month name, short form (

snd

from

months

locale

),

Jan

-

Dec

%m

month of year, 0-padded to two chars,

01

-

12

Day

For Day (and LocalTime and ZonedTime and UTCTime and UniversalTime):

%D

same as

%m/%d/%y

%F

same as

%Y-%m-%d

%x

as

dateFmt

locale

(e.g.

%m/%d/%y

)

%d

day of month, 0-padded to two chars,

01

-

31

%e

day of month, space-padded to two chars,

1

-

31

%j

day of year, 0-padded to three chars,

001

-

366

%f

century for Week Date format, no padding. Note

%0f

and

%_f

pad to two chars

%V

week of year for Week Date format, 0-padded to two chars,

01

-

53

%U

week of year where weeks start on Sunday (as

sundayStartWeek

), 0-padded to two chars,

00

-

53

%W

week of year where weeks start on Monday (as

mondayStartWeek

), 0-padded to two chars,

00

-

53

Duration types

The specifiers for DiffTime, NominalDiffTime, CalendarDiffDays, and CalendarDiffTime are semantically separate from the other types. Specifiers on negative time differences will generally be negative (think rem rather than mod).

NominalDiffTime and DiffTime

Note that a "minute" of DiffTime is simply 60 SI seconds, rather than a minute of civil time. Use NominalDiffTime to work with civil time, ignoring any leap seconds.

For NominalDiffTime and DiffTime:

%w

total whole weeks

%d

total whole days

%D

whole days of week

%h

total whole hours

%H

whole hours of day

%m

total whole minutes

%M

whole minutes of hour

%s

total whole seconds

%Es

total seconds, with decimal point and up to <width> (default 12) decimal places, without trailing zeros. For a whole number of seconds,

%Es

omits the decimal point unless padding is specified.

%0Es

total seconds, with decimal point and <width> (default 12) decimal places.

%S

whole seconds of minute

%ES

seconds of minute, with decimal point and up to <width> (default 12) decimal places, without trailing zeros. For a whole number of seconds,

%ES

omits the decimal point unless padding is specified.

%0ES

seconds of minute as two digits, with decimal point and <width> (default 12) decimal places.

CalendarDiffDays

For CalendarDiffDays (and CalendarDiffTime):

%y

total years

%b

total months

%B

months of year

%w

total weeks, not including months

%d

total days, not including months

%D

days of week

CalendarDiffTime

For CalendarDiffTime:

%h

total hours, not including months

%H

hours of day

%m

total minutes, not including months

%M

minutes of hour

%s

total whole seconds, not including months

%Es

total seconds, not including months, with decimal point and up to <width> (default 12) decimal places, without trailing zeros. For a whole number of seconds,

%Es

omits the decimal point unless padding is specified.

%0Es

total seconds, not including months, with decimal point and <width> (default 12) decimal places.

%S

whole seconds of minute

%ES

seconds of minute, with decimal point and up to <width> (default 12) decimal places, without trailing zeros. For a whole number of seconds,

%ES

omits the decimal point unless padding is specified.

%0ES

seconds of minute as two digits, with decimal point and <width> (default 12) decimal places.

Locale representing American usage.

knownTimeZones contains only the ten time-zones mentioned in RFC 822 sec. 5: "UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT". Note that the parsing functions will regardless parse "UTC", single-letter military time-zones, and +HHMM format.

valueparseTimeM
  1. :: (MonadFail m, ParseTime t)
  2. => Bool

    Accept leading and trailing whitespace?

  3. -> TimeLocale

    Time locale.

  4. -> String

    Format string.

  5. -> String

    Input string.

  6. -> m t

    Return the time value, or fail if the input could not be parsed using the given format.

#

Parses a time value given a format string. Missing information will be derived from 1970-01-01 00:00 UTC (which was a Thursday). Supports the same %-codes as formatTime, including %-, %_ and %0 modifiers, however padding widths are not supported. Case is not significant in the input string. Some variations in the input are accepted:

%z %Ez

accepts any of

±HHMM

or

±HH:MM

.

%Z %EZ

accepts any string of letters, or any of the formats accepted by

%z

.

%0Y

accepts exactly four digits.

%0G

accepts exactly four digits.

%0C

accepts exactly two digits.

%0f

accepts exactly two digits.

For example, to parse a date in YYYY-MM-DD format, while allowing the month and date to have optional leading zeros (notice the - modifier used for %m and %d):

Prelude Data.Time> parseTimeM True defaultTimeLocale "%Y-%-m-%-d" "2010-3-04" :: Maybe Day
Just 2010-03-04
valueparseTimeMultipleM
  1. :: (MonadFail m, ParseTime t)
  2. => Bool

    Accept leading and trailing whitespace?

  3. -> TimeLocale

    Time locale.

  4. -> [(String, String)]

    Pairs of (format string, input string).

  5. -> m t

    Return the time value, or fail if the input could not be parsed using the given format.

#

Parses a time value given a list of pairs of format and input. Resulting value is constructed from all provided specifiers.

Get the configured time-zone for a given time (varying as per summertime adjustments).

On Unix systems the output of this function depends on:

  1. The value of TZ environment variable (if set)

  2. The system time zone (usually configured by /etc/localtime symlink)

For details see tzset(3) and localtime(3).

Example:

> let t = UTCTime (fromGregorian 2021 7 1) 0
> getTimeZone t
CEST
> setEnv "TZ" "America/New_York" >> getTimeZone t
EDT
> setEnv "TZ" "Europe/Berlin" >> getTimeZone t
CEST

On Windows systems the output of this function depends on:

  1. The value of TZ environment variable (if set). See here for how Windows interprets this variable.

  2. The system time zone, configured in Settings

valuecont :: ((a -> r) -> r) -> Cont r a
#

Construct a continuation-passing computation from a function. (The inverse of runCont)

valueevalCont :: Cont r r -> r
#

The result of running a CPS computation with the identity as the final continuation.

valuemapContT :: (m r -> m r) -> ContT r m a -> ContT r m a
#

Apply a function to transform the result of a continuation-passing computation. This has a more restricted type than the map operations for other monad transformers, because ContT does not define a functor in the category of monads.

valuerunCont
  1. :: Cont r a

    continuation computation (Cont).

  2. -> (a -> r)

    the final continuation, which produces the final result (often id).

  3. -> r
#

The result of running a CPS computation with a given final continuation. (The inverse of cont)

valuewithExcept :: (e -> e') -> Except e a -> Except e' a
#

Transform any exceptions thrown by the computation using the given function (a specialization of withExceptT).

valuerunReader
  1. :: Reader r a

    A Reader to run.

  2. -> r

    An initial environment.

  3. -> a
#

Runs a Reader and extracts the final value from it. (The inverse of reader.)

valueevalState
  1. :: State s a

    state-passing computation to execute

  2. -> s

    initial value

  3. -> a

    return value of the state computation

#

Evaluate a state computation with the given initial state and return the final value, discarding the final state.

valueexecState
  1. :: State s a

    state-passing computation to execute

  2. -> s

    initial value

  3. -> s

    final state

#

Evaluate a state computation with the given initial state and return the final state, discarding the final value.

valuerunState
  1. :: State s a

    state-passing computation to execute

  2. -> s

    initial state

  3. -> (a, s)

    return value and final state

#

Unwrap a state monad computation as a function. (The inverse of state.)

valuerunWriter :: Writer w a -> (a, w)
#

Unwrap a writer computation as a (result, output) pair. (The inverse of writer.)

valueunsafeVacuous :: Functor f => f Void -> f a
#

If Void is uninhabited than any Functor that holds only values of the type Void is holding no values.

This is only safe for valid functors that do not perform GADT-like analysis on the argument.

valueunsafeVacuousM :: Monad m => m Void -> m a
#

If Void is uninhabited then any Monad that holds values of type Void is holding no values.

This is only safe for valid monads that do not perform GADT-like analysis on the argument.

newtypenewtype WrappedArrow (a :: Type -> Type -> Type) b c
#

Constructors

Instances14Generic1, Invariant2, Functor, Applicative, Alternative, Alt, …
newtypenewtype WrappedMonad (m :: Type -> Type) a
#

Constructors

Instances17Generic1, Monad, Functor, Applicative, Alternative, Distributive, …
classclass Monad m => MonadIO (m :: Type -> Type) where
#

Monads in which IO computations may be embedded. Any monad built by applying a sequence of monad transformers to the IO monad will be an instance of this class.

Instances should satisfy the following laws, which state that liftIO is a transformer of monads:

Methods

  • liftIO :: IO a -> m a

    Lift a computation from the IO monad. This allows us to run IO computations in any monadic stack, so long as it supports these kinds of operations (i.e. IO is the base monad for the stack).

    Example
    import Control.Monad.Trans.State -- from the "transformers" library
    
    printState :: Show s => StateT s IO ()
    printState = do
      state <- get
      liftIO $ print state

    Had we omitted liftIO, we would have ended up with this error:

    • Couldn't match type ‘IO’ with ‘StateT s IO’
     Expected type: StateT s IO ()
       Actual type: IO ()

    The important part here is the mismatch between StateT s IO () and IO ().

    Luckily, we know of a function that takes an IO a and returns an (m a): liftIO, enabling us to run the program and see the expected results:

    > evalStateT printState "hello"
    "hello"
    
    > evalStateT printState 3
    3
    
Instances26MonadIO, …
classclass Bifoldable t => Bifoldable1 (t :: Type -> Type -> Type) where
#

Methods

Instances15Bifoldable1, …
typetype Centi = Fixed E2
#

Resolution of 10^-2 = .01, useful for many monetary currencies

Examples
Example1 expression
show (MkFixed 12345 :: Fixed E2)"123.45"
Example1 expression
show (MkFixed 12345 :: Centi)"123.45"
typetype Deci = Fixed E1
#

Resolution of 10^-1 = .1

Examples
Example1 expression
show (MkFixed 12345 :: Fixed E1)"1234.5"
Example1 expression
show (MkFixed 12345 :: Deci)"1234.5"
datadata E0
#

Resolution of 1, this works the same as Integer.

Instances1HasResolution
datadata E1
#

Resolution of 10^-1 = .1

Instances1HasResolution
datadata E12
#

Resolution of 10^-12 = .000000000001

Instances1HasResolution
datadata E2
#

Resolution of 10^-2 = .01, useful for many monetary currencies

Instances1HasResolution
datadata E3
#

Resolution of 10^-3 = .001

Instances1HasResolution
datadata E6
#

Resolution of 10^-6 = .000001

Instances1HasResolution
datadata E9
#

Resolution of 10^-9 = .000000001

Instances1HasResolution
classclass HasResolution (a :: k) where
#

Types which can be used as a resolution argument to the Fixed type constructor must implement the HasResolution typeclass.

Methods

  • resolution :: p a -> Integer

    Provide the resolution for a fixed-point fractional number.

Instances10HasResolution, …
typetype Micro = Fixed E6
#

Resolution of 10^-6 = .000001

Examples
Example1 expression
show (MkFixed 12345 :: Fixed E6)"0.012345"
Example1 expression
show (MkFixed 12345 :: Micro)"0.012345"
typetype Milli = Fixed E3
#

Resolution of 10^-3 = .001

Examples
Example1 expression
show (MkFixed 12345 :: Fixed E3)"12.345"
Example1 expression
show (MkFixed 12345 :: Milli)"12.345"
typetype Nano = Fixed E9
#

Resolution of 10^-9 = .000000001

Examples
Example1 expression
show (MkFixed 12345 :: Fixed E9)"0.000012345"
Example1 expression
show (MkFixed 12345 :: Nano)"0.000012345"
typetype Pico = Fixed E12
#

Resolution of 10^-12 = .000000000001

Examples
Example1 expression
show (MkFixed 12345 :: Fixed E12)"0.000000012345"
Example1 expression
show (MkFixed 12345 :: Pico)"0.000000012345"
typetype Uni = Fixed E0
#

Resolution of 1, this works the same as Integer.

Examples
Example1 expression
show (MkFixed 12345 :: Fixed E0)"12345.0"
Example1 expression
show (MkFixed 12345 :: Uni)"12345.0"
classclass Foldable t => Foldable1 (t :: Type -> Type) where
#

Non-empty data structures that can be folded.

Methods

  • fold1 :: Semigroup m => t m -> m

    Given a structure with elements whose type is a Semigroup, combine them via the semigroup's (<>) operator. This fold is right-associative and lazy in the accumulator. When you need a strict left-associative fold, use foldMap1' instead, with id as the map.

  • foldMap1 :: Semigroup m => (a -> m) -> t a -> m

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

    Example1 expression
    foldMap1 (:[]) (1 :| [2, 3, 4])[1,2,3,4]
  • toNonEmpty :: t a -> NonEmpty a

    NonEmpty list of elements of a structure, from left to right.

    Example1 expression
    toNonEmpty (Identity 2)2 :| []
Instances43Foldable1, …
classclass (forall a. Eq a => Eq (f a)) => Eq1 (f :: Type -> Type) where
#

Lifting of the Eq class to unary type constructors.

Any instance should be subject to the following law that canonicity is preserved:

liftEq (==) = (==)

This class therefore represents the generalization of Eq by decomposing its main method into a canonical lifting on a canonical inner method, so that the lifting can be reused for other arguments than the canonical one.

Methods

  • liftEq :: (a -> b -> Bool) -> f a -> f b -> Bool

    Lift an equality test through the type constructor.

    The function will usually be applied to an equality function, but the more general type ensures that the implementation uses it to compare elements of the first container with elements of the second.

Instances83Eq1, …
  • Eq1 ComplexDefined in base-4.20.2.0 · Data.Functor.Classes
    Example1 expression
    eq1 (1 :+ 2) (1 :+ 2)True
    Example1 expression
    eq1 (1 :+ 2) (1 :+ 3)False
  • Eq1 SCCDefined in containers-0.7 · Data.Graph
  • Eq1 IntMapDefined in containers-0.7 · Data.IntMap.Internal
  • Eq1 SeqDefined in containers-0.7 · Data.Sequence.Internal
  • Eq1 SetDefined in containers-0.7 · Data.Set.Internal
  • Eq1 TreeDefined in containers-0.7 · Data.Tree
  • Eq1 NonEmptyDefined in base-4.20.2.0 · Data.Functor.Classes
  • Eq1 IdentityDefined in base-4.20.2.0 · Data.Functor.Classes
  • Eq1 DownDefined in base-4.20.2.0 · Data.Functor.Classes
  • Eq1 Par1Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Eq1 MaybeDefined in base-4.20.2.0 · Data.Functor.Classes
  • Eq1 SoloDefined in base-4.20.2.0 · Data.Functor.Classes
  • Eq1 HashedDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Eq1 ArrayDefined in primitive-0.9.1.0 · Data.Primitive.Array
  • Eq1 SmallArrayDefined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • Eq1 HashSetDefined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Eq1 VectorDefined in vector-0.13.2.0 · Data.Vector
  • Eq1 VectorDefined in vector-0.13.2.0 · Data.Vector.Strict
  • Eq1 []Defined in base-4.20.2.0 · Data.Functor.Classes
  • Eq1 ProxyDefined in base-4.20.2.0 · Data.Functor.Classes
  • Eq1 U1Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Eq1 UAddrDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Eq1 UCharDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Eq1 UDoubleDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Eq1 UFloatDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Eq1 UIntDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Eq1 UWordDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Eq1 V1Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Eq1 f => Eq1 (Ap f)Defined in free-5.2 · Control.Applicative.Free
  • Eq1 f => Eq1 (Cofree f)Defined in free-5.2 · Control.Comonad.Cofree
  • Eq1 f => Eq1 (Free f)Defined in free-5.2 · Control.Monad.Free
  • Eq1 f => Eq1 (Free f)Defined in free-5.2 · Control.Monad.Free.Ap
  • Eq1 f => Eq1 (Coyoneda f)Defined in kan-extensions-5.2.7 · Data.Functor.Coyoneda
  • Eq1 f => Eq1 (Yoneda f)Defined in kan-extensions-5.2.7 · Data.Functor.Yoneda
  • Eq1 f => Eq1 (Lift f)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • Eq1 m => Eq1 (IterT m)Defined in free-5.2 · Control.Monad.Trans.Iter
  • Eq1 m => Eq1 (MaybeT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • Eq1 w => Eq1 (CoiterT w)Defined in free-5.2 · Control.Comonad.Trans.Coiter
  • Eq a => Eq1 (Either a)Defined in base-4.20.2.0 · Data.Functor.Classes
  • Eq a => Eq1 (Tuple2 a)Defined in base-4.20.2.0 · Data.Functor.Classes
  • Eq k => Eq1 (Map k)Defined in containers-0.7 · Data.Map.Internal
  • Eq k => Eq1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (GEq1 NonV4 (Rep1 f), Generic1 f) => Eq1 (FunctorClassesDefault f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Eq1 (Tagged s)Defined in tagged-0.8.9 · Data.Tagged
  • Eq1 (Bundle Id v)Defined in vector-0.13.2.0 · Data.Vector.Fusion.Bundle · orphan
  • Eq1 (bi a) => Eq1 (Biap bi a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biap
  • Eq1 f => Eq1 (Rec1 f)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Eq1 f => Eq1 (Backwards f)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • Eq1 f => Eq1 (IdentityT f)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • Eq1 f => Eq1 (Reverse f)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • Eq2 p => Eq1 (Fix p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Fix
  • Eq2 p => Eq1 (Join p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Join
  • Eq a => Eq1 (Const a)Defined in base-4.20.2.0 · Data.Functor.Classes
  • Eq a => Eq1 (Constant a)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • (Eq1 f, Eq1 m) => Eq1 (FreeT f m)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Eq1 f, Eq1 m) => Eq1 (FreeT f m)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Eq1 f, Eq a) => Eq1 (CofreeF f a)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • (Eq1 f, Eq a) => Eq1 (FreeF f a)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Eq1 f, Eq a) => Eq1 (FreeF f a)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Eq1 f, Eq e) => Eq1 (ExceptT e f)Defined in selective-0.7.0.1 · Control.Selective.Trans.Except
  • (Functor f, Monad m, Eq1 f, Eq1 m) => Eq1 (FT f m)Defined in free-5.2 · Control.Monad.Trans.Free.Church
  • (Generic1 f, Eq1 (Rep1 f)) => Eq1 (Generically1 f)Defined in base-4.20.2.0 · Data.Functor.Classes
  • (Eq a, Eq b) => Eq1 (Tuple3 a b)Defined in base-4.20.2.0 · Data.Functor.Classes
  • (Eq e, Eq1 m) => Eq1 (ExceptT e m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • (Eq w, Eq1 m) => Eq1 (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Eq w, Eq1 m) => Eq1 (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • Eq c => Eq1 (K1 i c)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • (Eq1 f, Eq1 g) => Eq1 (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Eq1 f, Eq1 g) => Eq1 (Sum f g)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Eq1 f, Eq1 g) => Eq1 (f :*: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • (Eq1 f, Eq1 g) => Eq1 (f :+: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • (Eq a, Eq b, Eq c) => Eq1 (Tuple4 a b c)Defined in base-4.20.2.0 · Data.Functor.Classes
  • Eq1 f => Eq1 (M1 i c f)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Eq1 g => Eq1 (Joker g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Joker
  • (Eq1 f, Eq1 g) => Eq1 (Compose f g)Defined in base-4.20.2.0 · Data.Functor.Compose
  • (Eq1 f, Eq1 g) => Eq1 (f :.: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • (Eq1 f, Eq a) => Eq1 (Clown f a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Clown
  • (Eq2 p, Eq a) => Eq1 (Flip p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Flip
  • (Eq2 p, Eq a) => Eq1 (WrappedBifunctor p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Wrapped
  • (Eq2 f, Eq2 g, Eq a) => Eq1 (Product f g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Product
  • (Eq2 f, Eq2 g, Eq a) => Eq1 (Sum f g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Sum
  • (Eq1 f, Eq2 p, Eq a) => Eq1 (Tannen f p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Tannen
  • (Eq2 p, Eq1 f, Eq1 g, Eq a) => Eq1 (Biff p f g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biff
classclass (forall a. Eq a => Eq1 (f a)) => Eq2 (f :: Type -> Type -> Type) where
#

Lifting of the Eq class to binary type constructors.

Methods

  • liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool

    Lift equality tests through the type constructor.

    The function will usually be applied to equality functions, but the more general type ensures that the implementation uses them to compare elements of the first container with elements of the second.

Instances21Eq2, …
  • Eq2 MapDefined in containers-0.7 · Data.Map.Internal
  • Eq2 EitherDefined in base-4.20.2.0 · Data.Functor.Classes
  • Eq2 Tuple2Defined in base-4.20.2.0 · Data.Functor.Classes
  • Eq2 HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Eq1 f => Eq2 (CofreeF f)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • Eq1 f => Eq2 (FreeF f)Defined in free-5.2 · Control.Monad.Trans.Free
  • Eq1 f => Eq2 (FreeF f)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • Eq2 ConstDefined in base-4.20.2.0 · Data.Functor.Classes
  • Eq2 TaggedDefined in tagged-0.8.9 · Data.Tagged
  • Eq2 ConstantDefined in transformers-0.6.1.1 · Data.Functor.Constant
  • Eq2 bi => Eq2 (Biap bi)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biap
  • Eq a => Eq2 (Tuple3 a)Defined in base-4.20.2.0 · Data.Functor.Classes
    Example1 expression
    eq2 ('x', True, "str") ('x', True, "str")True
  • (Eq a, Eq b) => Eq2 (Tuple4 a b)Defined in base-4.20.2.0 · Data.Functor.Classes
    Example1 expression
    eq2 ('x', True, "str", 2) ('x', True, "str", 2 :: Int)True
  • Eq1 f => Eq2 (Clown f)Defined in bifunctors-5.6.2 · Data.Bifunctor.Clown
  • Eq1 g => Eq2 (Joker g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Joker
  • Eq2 p => Eq2 (Flip p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Flip
  • Eq2 p => Eq2 (WrappedBifunctor p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Wrapped
  • (Eq2 f, Eq2 g) => Eq2 (Product f g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Product
  • (Eq2 f, Eq2 g) => Eq2 (Sum f g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Sum
  • (Eq1 f, Eq2 p) => Eq2 (Tannen f p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Tannen
  • (Eq2 p, Eq1 f, Eq1 g) => Eq2 (Biff p f g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biff
classclass (Eq1 f, forall a. Ord a => Ord (f a)) => Ord1 (f :: Type -> Type) where
#

Lifting of the Ord class to unary type constructors.

Any instance should be subject to the following law that canonicity is preserved:

liftCompare compare = compare

This class therefore represents the generalization of Ord by decomposing its main method into a canonical lifting on a canonical inner method, so that the lifting can be reused for other arguments than the canonical one.

Methods

  • liftCompare :: (a -> b -> Ordering) -> f a -> f b -> Ordering

    Lift a compare function through the type constructor.

    The function will usually be applied to a comparison function, but the more general type ensures that the implementation uses it to compare elements of the first container with elements of the second.

Instances81Ord1, …
  • Ord1 IntMapDefined in containers-0.7 · Data.IntMap.Internal
  • Ord1 SeqDefined in containers-0.7 · Data.Sequence.Internal
  • Ord1 SetDefined in containers-0.7 · Data.Set.Internal
  • Ord1 TreeDefined in containers-0.7 · Data.Tree
  • Ord1 NonEmptyDefined in base-4.20.2.0 · Data.Functor.Classes
  • Ord1 IdentityDefined in base-4.20.2.0 · Data.Functor.Classes
  • Ord1 DownDefined in base-4.20.2.0 · Data.Functor.Classes
  • Ord1 Par1Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Ord1 MaybeDefined in base-4.20.2.0 · Data.Functor.Classes
  • Ord1 SoloDefined in base-4.20.2.0 · Data.Functor.Classes
  • Ord1 HashedDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Ord1 ArrayDefined in primitive-0.9.1.0 · Data.Primitive.Array
  • Ord1 SmallArrayDefined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • Ord1 HashSetDefined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Ord1 VectorDefined in vector-0.13.2.0 · Data.Vector
  • Ord1 VectorDefined in vector-0.13.2.0 · Data.Vector.Strict
  • Ord1 []Defined in base-4.20.2.0 · Data.Functor.Classes
  • Ord1 ProxyDefined in base-4.20.2.0 · Data.Functor.Classes
  • Ord1 U1Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Ord1 UAddrDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Ord1 UCharDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Ord1 UDoubleDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Ord1 UFloatDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Ord1 UIntDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Ord1 UWordDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Ord1 V1Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Ord1 f => Ord1 (Ap f)Defined in free-5.2 · Control.Applicative.Free
  • Ord1 f => Ord1 (Cofree f)Defined in free-5.2 · Control.Comonad.Cofree
  • Ord1 f => Ord1 (Free f)Defined in free-5.2 · Control.Monad.Free
  • Ord1 f => Ord1 (Free f)Defined in free-5.2 · Control.Monad.Free.Ap
  • Ord1 f => Ord1 (Coyoneda f)Defined in kan-extensions-5.2.7 · Data.Functor.Coyoneda
  • Ord1 f => Ord1 (Yoneda f)Defined in kan-extensions-5.2.7 · Data.Functor.Yoneda
  • Ord1 f => Ord1 (Lift f)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • Ord1 m => Ord1 (IterT m)Defined in free-5.2 · Control.Monad.Trans.Iter
  • Ord1 m => Ord1 (MaybeT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • Ord1 w => Ord1 (CoiterT w)Defined in free-5.2 · Control.Comonad.Trans.Coiter
  • Ord a => Ord1 (Either a)Defined in base-4.20.2.0 · Data.Functor.Classes
  • Ord a => Ord1 (Tuple2 a)Defined in base-4.20.2.0 · Data.Functor.Classes
  • Ord k => Ord1 (Map k)Defined in containers-0.7 · Data.Map.Internal
  • Ord k => Ord1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (GOrd1 NonV4 (Rep1 f), Generic1 f) => Ord1 (FunctorClassesDefault f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Ord1 (Tagged s)Defined in tagged-0.8.9 · Data.Tagged
  • Ord1 (Bundle Id v)Defined in vector-0.13.2.0 · Data.Vector.Fusion.Bundle · orphan
  • Ord1 (bi a) => Ord1 (Biap bi a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biap
  • Ord1 f => Ord1 (Rec1 f)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Ord1 f => Ord1 (Backwards f)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • Ord1 f => Ord1 (IdentityT f)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • Ord1 f => Ord1 (Reverse f)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • Ord2 p => Ord1 (Fix p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Fix
  • Ord2 p => Ord1 (Join p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Join
  • Ord a => Ord1 (Const a)Defined in base-4.20.2.0 · Data.Functor.Classes
  • Ord a => Ord1 (Constant a)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • (Ord1 f, Ord1 m) => Ord1 (FreeT f m)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Ord1 f, Ord1 m) => Ord1 (FreeT f m)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Ord1 f, Ord a) => Ord1 (CofreeF f a)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • (Ord1 f, Ord a) => Ord1 (FreeF f a)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Ord1 f, Ord a) => Ord1 (FreeF f a)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Ord1 f, Ord e) => Ord1 (ExceptT e f)Defined in selective-0.7.0.1 · Control.Selective.Trans.Except
  • (Functor f, Monad m, Ord1 f, Ord1 m) => Ord1 (FT f m)Defined in free-5.2 · Control.Monad.Trans.Free.Church
  • (Generic1 f, Ord1 (Rep1 f)) => Ord1 (Generically1 f)Defined in base-4.20.2.0 · Data.Functor.Classes
  • (Ord a, Ord b) => Ord1 (Tuple3 a b)Defined in base-4.20.2.0 · Data.Functor.Classes
  • (Ord e, Ord1 m) => Ord1 (ExceptT e m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • (Ord w, Ord1 m) => Ord1 (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Ord w, Ord1 m) => Ord1 (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • Ord c => Ord1 (K1 i c)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • (Ord1 f, Ord1 g) => Ord1 (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Ord1 f, Ord1 g) => Ord1 (Sum f g)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Ord1 f, Ord1 g) => Ord1 (f :*: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • (Ord1 f, Ord1 g) => Ord1 (f :+: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • (Ord a, Ord b, Ord c) => Ord1 (Tuple4 a b c)Defined in base-4.20.2.0 · Data.Functor.Classes
  • Ord1 f => Ord1 (M1 i c f)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Ord1 g => Ord1 (Joker g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Joker
  • (Ord1 f, Ord1 g) => Ord1 (Compose f g)Defined in base-4.20.2.0 · Data.Functor.Compose
  • (Ord1 f, Ord1 g) => Ord1 (f :.: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • (Ord1 f, Ord a) => Ord1 (Clown f a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Clown
  • (Ord2 p, Ord a) => Ord1 (Flip p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Flip
  • (Ord2 p, Ord a) => Ord1 (WrappedBifunctor p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Wrapped
  • (Ord2 f, Ord2 g, Ord a) => Ord1 (Product f g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Product
  • (Ord2 f, Ord2 g, Ord a) => Ord1 (Sum f g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Sum
  • (Ord1 f, Ord2 p, Ord a) => Ord1 (Tannen f p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Tannen
  • (Ord2 p, Ord1 f, Ord1 g, Ord a) => Ord1 (Biff p f g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biff
classclass (Eq2 f, forall a. Ord a => Ord1 (f a)) => Ord2 (f :: Type -> Type -> Type) where
#

Lifting of the Ord class to binary type constructors.

Methods

  • liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> f a c -> f b d -> Ordering

    Lift compare functions through the type constructor.

    The function will usually be applied to comparison functions, but the more general type ensures that the implementation uses them to compare elements of the first container with elements of the second.

Instances21Ord2, …
  • Ord2 MapDefined in containers-0.7 · Data.Map.Internal
  • Ord2 EitherDefined in base-4.20.2.0 · Data.Functor.Classes
  • Ord2 Tuple2Defined in base-4.20.2.0 · Data.Functor.Classes
  • Ord2 HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Ord1 f => Ord2 (CofreeF f)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • Ord1 f => Ord2 (FreeF f)Defined in free-5.2 · Control.Monad.Trans.Free
  • Ord1 f => Ord2 (FreeF f)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • Ord2 ConstDefined in base-4.20.2.0 · Data.Functor.Classes
  • Ord2 TaggedDefined in tagged-0.8.9 · Data.Tagged
  • Ord2 ConstantDefined in transformers-0.6.1.1 · Data.Functor.Constant
  • Ord2 bi => Ord2 (Biap bi)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biap
  • Ord a => Ord2 (Tuple3 a)Defined in base-4.20.2.0 · Data.Functor.Classes
    Example1 expression
    compare2 ('x', True, "aaa") ('x', True, "zzz")LT
  • (Ord a, Ord b) => Ord2 (Tuple4 a b)Defined in base-4.20.2.0 · Data.Functor.Classes
    Example1 expression
    compare2 ('x', True, "str", 2) ('x', True, "str", 3 :: Int)LT
  • Ord1 f => Ord2 (Clown f)Defined in bifunctors-5.6.2 · Data.Bifunctor.Clown
  • Ord1 g => Ord2 (Joker g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Joker
  • Ord2 p => Ord2 (Flip p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Flip
  • Ord2 p => Ord2 (WrappedBifunctor p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Wrapped
  • (Ord2 f, Ord2 g) => Ord2 (Product f g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Product
  • (Ord2 f, Ord2 g) => Ord2 (Sum f g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Sum
  • (Ord1 f, Ord2 p) => Ord2 (Tannen f p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Tannen
  • (Ord2 p, Ord1 f, Ord1 g) => Ord2 (Biff p f g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biff
classclass (forall a. Read a => Read (f a)) => Read1 (f :: Type -> Type) where
#

Lifting of the Read class to unary type constructors.

Any instance should be subject to the following laws that canonicity is preserved:

liftReadsPrec readsPrec readList = readsPrec

liftReadList readsPrec readList = readList

liftReadPrec readPrec readListPrec = readPrec

liftReadListPrec readPrec readListPrec = readListPrec

This class therefore represents the generalization of Read by decomposing it's methods into a canonical lifting on a canonical inner method, so that the lifting can be reused for other arguments than the canonical one.

Both liftReadsPrec and liftReadPrec exist to match the interface provided in the Read type class, but it is recommended to implement Read1 instances using liftReadPrec as opposed to liftReadsPrec, since the former is more efficient than the latter. For example:

instance Read1 T where
  liftReadPrec     = ...
  liftReadListPrec = liftReadListPrecDefault

For more information, refer to the documentation for the Read class.

Methods

Instances69Read1, …
classclass (forall a. Read a => Read1 (f a)) => Read2 (f :: Type -> Type -> Type) where
#

Lifting of the Read class to binary type constructors.

Both liftReadsPrec2 and liftReadPrec2 exist to match the interface provided in the Read type class, but it is recommended to implement Read2 instances using liftReadPrec2 as opposed to liftReadsPrec2, since the former is more efficient than the latter. For example:

instance Read2 T where
  liftReadPrec2     = ...
  liftReadListPrec2 = liftReadListPrec2Default

For more information, refer to the documentation for the Read class.

Methods

Instances18Read2, …
  • Read2 EitherDefined in base-4.20.2.0 · Data.Functor.Classes
  • Read2 Tuple2Defined in base-4.20.2.0 · Data.Functor.Classes
  • Read1 f => Read2 (CofreeF f)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • Read1 f => Read2 (FreeF f)Defined in free-5.2 · Control.Monad.Trans.Free
  • Read1 f => Read2 (FreeF f)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • Read2 ConstDefined in base-4.20.2.0 · Data.Functor.Classes
  • Read2 TaggedDefined in tagged-0.8.9 · Data.Tagged
  • Read2 ConstantDefined in transformers-0.6.1.1 · Data.Functor.Constant
  • Read a => Read2 (Tuple3 a)Defined in base-4.20.2.0 · Data.Functor.Classes
    Example1 expression
    readPrec_to_S readPrec2 0 "('x', True, 2)" :: [((Char, Bool, Int), String)][(('x',True,2),"")]
  • (Read a, Read b) => Read2 (Tuple4 a b)Defined in base-4.20.2.0 · Data.Functor.Classes
    Example1 expression
    readPrec_to_S readPrec2 0 "('x', True, 2, 4.5)" :: [((Char, Bool, Int, Double), String)][(('x',True,2,4.5),"")]
  • Read1 f => Read2 (Clown f)Defined in bifunctors-5.6.2 · Data.Bifunctor.Clown
  • Read1 g => Read2 (Joker g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Joker
  • Read2 p => Read2 (Flip p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Flip
  • Read2 p => Read2 (WrappedBifunctor p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Wrapped
  • (Read2 f, Read2 g) => Read2 (Product f g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Product
  • (Read2 f, Read2 g) => Read2 (Sum f g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Sum
  • (Read1 f, Read2 p) => Read2 (Tannen f p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Tannen
  • (Read2 p, Read1 f, Read1 g) => Read2 (Biff p f g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biff
classclass (forall a. Show a => Show (f a)) => Show1 (f :: Type -> Type) where
#

Lifting of the Show class to unary type constructors.

Any instance should be subject to the following laws that canonicity is preserved:

liftShowsPrec showsPrec showList = showsPrec

liftShowList showsPrec showList = showList

This class therefore represents the generalization of Show by decomposing it's methods into a canonical lifting on a canonical inner method, so that the lifting can be reused for other arguments than the canonical one.

Methods

Instances78Show1, …
  • Show1 ComplexDefined in base-4.20.2.0 · Data.Functor.Classes
    Example1 expression
    showsPrec1 0 (2 :+ 3) """2 :+ 3"
  • Show1 SCCDefined in containers-0.7 · Data.Graph
  • Show1 IntMapDefined in containers-0.7 · Data.IntMap.Internal
  • Show1 SeqDefined in containers-0.7 · Data.Sequence.Internal
  • Show1 SetDefined in containers-0.7 · Data.Set.Internal
  • Show1 TreeDefined in containers-0.7 · Data.Tree
  • Show1 NonEmptyDefined in base-4.20.2.0 · Data.Functor.Classes
  • Show1 IdentityDefined in base-4.20.2.0 · Data.Functor.Classes
  • Show1 DownDefined in base-4.20.2.0 · Data.Functor.Classes
  • Show1 Par1Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Show1 MaybeDefined in base-4.20.2.0 · Data.Functor.Classes
  • Show1 SoloDefined in base-4.20.2.0 · Data.Functor.Classes
  • Show1 HashedDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Show1 ArrayDefined in primitive-0.9.1.0 · Data.Primitive.Array
  • Show1 SmallArrayDefined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • Show1 HashSetDefined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Show1 VectorDefined in vector-0.13.2.0 · Data.Vector
  • Show1 VectorDefined in vector-0.13.2.0 · Data.Vector.Strict
  • Show1 []Defined in base-4.20.2.0 · Data.Functor.Classes
  • Show1 ProxyDefined in base-4.20.2.0 · Data.Functor.Classes
  • Show1 U1Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Show1 UAddrDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Show1 UCharDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Show1 UDoubleDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Show1 UFloatDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Show1 UIntDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Show1 UWordDefined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Show1 V1Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Show1 f => Show1 (Cofree f)Defined in free-5.2 · Control.Comonad.Cofree
  • Show1 f => Show1 (Free f)Defined in free-5.2 · Control.Monad.Free
  • Show1 f => Show1 (Free f)Defined in free-5.2 · Control.Monad.Free.Ap
  • Show1 f => Show1 (Yoneda f)Defined in kan-extensions-5.2.7 · Data.Functor.Yoneda
  • Show1 f => Show1 (Lift f)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • Show1 m => Show1 (IterT m)Defined in free-5.2 · Control.Monad.Trans.Iter
  • Show1 m => Show1 (MaybeT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • Show1 w => Show1 (CoiterT w)Defined in free-5.2 · Control.Comonad.Trans.Coiter
  • Show a => Show1 (Either a)Defined in base-4.20.2.0 · Data.Functor.Classes
  • Show a => Show1 (Tuple2 a)Defined in base-4.20.2.0 · Data.Functor.Classes
  • Show k => Show1 (Map k)Defined in containers-0.7 · Data.Map.Internal
  • Show k => Show1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (Functor f, Show1 f) => Show1 (Coyoneda f)Defined in kan-extensions-5.2.7 · Data.Functor.Coyoneda
  • (GShow1 NonV4 (Rep1 f), Generic1 f) => Show1 (FunctorClassesDefault f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Show1 (Tagged s)Defined in tagged-0.8.9 · Data.Tagged
  • Show1 f => Show1 (Rec1 f)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Show1 f => Show1 (Backwards f)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • Show1 f => Show1 (IdentityT f)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • Show1 f => Show1 (Reverse f)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • Show2 p => Show1 (Fix p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Fix
  • Show2 p => Show1 (Join p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Join
  • Show a => Show1 (Const a)Defined in base-4.20.2.0 · Data.Functor.Classes
  • Show a => Show1 (Constant a)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • (Show1 f, Show1 m) => Show1 (FreeT f m)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Show1 f, Show1 m) => Show1 (FreeT f m)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Show1 f, Show a) => Show1 (CofreeF f a)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • (Show1 f, Show a) => Show1 (FreeF f a)Defined in free-5.2 · Control.Monad.Trans.Free
  • (Show1 f, Show a) => Show1 (FreeF f a)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • (Show1 f, Show e) => Show1 (ExceptT e f)Defined in selective-0.7.0.1 · Control.Selective.Trans.Except
  • (Show a, Show b) => Show1 (Tuple3 a b)Defined in base-4.20.2.0 · Data.Functor.Classes
  • (Show e, Show1 m) => Show1 (ExceptT e m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • (Show w, Show1 m) => Show1 (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Show w, Show1 m) => Show1 (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • Show c => Show1 (K1 i c)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • (Show1 f, Show1 g) => Show1 (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Show1 f, Show1 g) => Show1 (Sum f g)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Show1 f, Show1 g) => Show1 (f :*: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • (Show1 f, Show1 g) => Show1 (f :+: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • (Show a, Show b, Show c) => Show1 (Tuple4 a b c)Defined in base-4.20.2.0 · Data.Functor.Classes
  • Show1 f => Show1 (M1 i c f)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Show1 g => Show1 (Joker g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Joker
  • (Show1 f, Show1 g) => Show1 (Compose f g)Defined in base-4.20.2.0 · Data.Functor.Compose
  • (Show1 f, Show1 g) => Show1 (f :.: g)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • (Show1 f, Show a) => Show1 (Clown f a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Clown
  • (Show2 p, Show a) => Show1 (Flip p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Flip
  • (Show2 p, Show a) => Show1 (WrappedBifunctor p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Wrapped
  • (Show2 f, Show2 g, Show a) => Show1 (Product f g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Product
  • (Show2 f, Show2 g, Show a) => Show1 (Sum f g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Sum
  • (Show1 f, Show2 p, Show a) => Show1 (Tannen f p a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Tannen
  • (Show2 p, Show1 f, Show1 g, Show a) => Show1 (Biff p f g a)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biff
classclass (forall a. Show a => Show1 (f a)) => Show2 (f :: Type -> Type -> Type) where
#

Lifting of the Show class to binary type constructors.

Methods

Instances20Show2, …
  • Show2 MapDefined in containers-0.7 · Data.Map.Internal
  • Show2 EitherDefined in base-4.20.2.0 · Data.Functor.Classes
  • Show2 Tuple2Defined in base-4.20.2.0 · Data.Functor.Classes
  • Show2 HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Show1 f => Show2 (CofreeF f)Defined in free-5.2 · Control.Comonad.Trans.Cofree
  • Show1 f => Show2 (FreeF f)Defined in free-5.2 · Control.Monad.Trans.Free
  • Show1 f => Show2 (FreeF f)Defined in free-5.2 · Control.Monad.Trans.Free.Ap
  • Show2 ConstDefined in base-4.20.2.0 · Data.Functor.Classes
  • Show2 TaggedDefined in tagged-0.8.9 · Data.Tagged
  • Show2 ConstantDefined in transformers-0.6.1.1 · Data.Functor.Constant
  • Show a => Show2 (Tuple3 a)Defined in base-4.20.2.0 · Data.Functor.Classes
    Example1 expression
    showsPrec2 0 ('x', True, 2 :: Int) """('x',True,2)"
  • (Show a, Show b) => Show2 (Tuple4 a b)Defined in base-4.20.2.0 · Data.Functor.Classes
    Example1 expression
    showsPrec2 0 ('x', True, 2 :: Int, 4.5 :: Double) """('x',True,2,4.5)"
  • Show1 f => Show2 (Clown f)Defined in bifunctors-5.6.2 · Data.Bifunctor.Clown
  • Show1 g => Show2 (Joker g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Joker
  • Show2 p => Show2 (Flip p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Flip
  • Show2 p => Show2 (WrappedBifunctor p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Wrapped
  • (Show2 f, Show2 g) => Show2 (Product f g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Product
  • (Show2 f, Show2 g) => Show2 (Sum f g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Sum
  • (Show1 f, Show2 p) => Show2 (Tannen f p)Defined in bifunctors-5.6.2 · Data.Bifunctor.Tannen
  • (Show2 p, Show1 f, Show1 g) => Show2 (Biff p f g)Defined in bifunctors-5.6.2 · Data.Bifunctor.Biff
newtypenewtype Comparison a
#

Defines a total ordering on a type as per compare.

This condition is not checked by the types. You must ensure that the supplied values are valid total orderings yourself.

Constructors

Instances9Contravariant, Decidable, Divisible, Conclude, Decide, Divise, …
  • Contravariant ComparisonDefined in base-4.20.2.0 · Data.Functor.Contravariant

    A Comparison is a Contravariant Functor, because contramap can apply its function argument to each input of the comparison function.

  • Decidable ComparisonDefined in contravariant-1.5.5 · Data.Functor.Contravariant.Divisible
  • Divisible ComparisonDefined in contravariant-1.5.5 · Data.Functor.Contravariant.Divisible
  • Conclude ComparisonDefined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Conclude
  • Decide ComparisonDefined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Decide
  • Divise ComparisonDefined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Divise
  • Invariant ComparisonDefined in invariant-0.6.4 · Data.Functor.Invariant

    from the contravariant package

  • Semigroup (Comparison a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    (<>) on comparisons combines results with (<>) @Ordering. Without newtypes this equals liftA2 (liftA2 (<>)).

    (<>) :: Comparison a -> Comparison a -> Comparison a
    Comparison cmp <> Comparison cmp' = Comparison a a' ->
      cmp a a' <> cmp a a'
    
  • 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
    
newtypenewtype Equivalence a
#

This data type represents an equivalence relation.

Equivalence relations are expected to satisfy three laws:

Reflexivity

getEquivalence f a a = True

Symmetry

getEquivalence f a b = getEquivalence f b a

Transitivity

If

getEquivalence f a b

and

getEquivalence f b c

are both

True

then so is

getEquivalence f a c

.

The types alone do not enforce these laws, so you'll have to check them yourself.

Constructors

Instances9Contravariant, Decidable, Divisible, Conclude, Decide, Divise, …
  • Contravariant EquivalenceDefined in base-4.20.2.0 · Data.Functor.Contravariant

    Equivalence relations are Contravariant, because you can apply the contramapped function to each input to the equivalence relation.

  • Decidable EquivalenceDefined in contravariant-1.5.5 · Data.Functor.Contravariant.Divisible
  • Divisible EquivalenceDefined in contravariant-1.5.5 · Data.Functor.Contravariant.Divisible
  • Conclude EquivalenceDefined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Conclude
  • Decide EquivalenceDefined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Decide
  • Divise EquivalenceDefined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Divise
  • Invariant EquivalenceDefined in invariant-0.6.4 · Data.Functor.Invariant

    from the contravariant package

  • Semigroup (Equivalence a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    (<>) on equivalences uses logical conjunction (&&) on the results. Without newtypes this equals liftA2 (liftA2 (&&)).

    (<>) :: Equivalence a -> Equivalence a -> Equivalence a
    Equivalence equiv <> Equivalence equiv' = Equivalence a b ->
      equiv a b && equiv' a b
    
  • 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
    
newtypenewtype Op a b
#

Dual function arrows.

Constructors

Instances20Invariant2, Category, Semigroupoid, Contravariant, Decidable, Divisible, …
  • Invariant2 OpDefined in invariant-0.6.4 · Data.Functor.Invariant

    from the contravariant package

  • Category OpDefined in base-4.20.2.0 · Data.Functor.Contravariant
  • Semigroupoid OpDefined in semigroupoids-6.0.1 · Data.Semigroupoid
  • Contravariant (Op a)Defined in base-4.20.2.0 · Data.Functor.Contravariant
  • Monoid r => Decidable (Op r)Defined in contravariant-1.5.5 · Data.Functor.Contravariant.Divisible
  • Monoid r => Divisible (Op r)Defined in contravariant-1.5.5 · Data.Functor.Contravariant.Divisible
  • Conclude (Op r)Defined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Conclude
  • Decide (Op r)Defined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Decide

    Unlike Decidable, requires no constraint on r.

  • Semigroup r => Divise (Op r)Defined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Divise

    Unlike Divisible, requires only Semigroup on r.

  • Representable (Op r)Defined in adjunctions-4.4.3 · Data.Functor.Contravariant.Rep
  • Invariant (Op a)Defined in invariant-0.6.4 · Data.Functor.Invariant

    from the contravariant package

  • Adjunction (Op r) (Op r)Defined in adjunctions-4.4.3 · Data.Functor.Contravariant.Adjunction

    This Adjunction gives rise to the Cont Monad

  • Floating a => Floating (Op a b)Defined in base-4.20.2.0 · Data.Functor.Contravariant
  • Fractional a => Fractional (Op a b)Defined in base-4.20.2.0 · Data.Functor.Contravariant
  • Num a => Num (Op a b)Defined in base-4.20.2.0 · Data.Functor.Contravariant
  • Semigroup a => Semigroup (Op a b)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    (<>) @(Op a b) without newtypes is (<>) @(b->a) = liftA2 (<>). This lifts the Semigroup operation (<>) over the output of a.

    (<>) :: Op a b -> Op a b -> Op a b
    Op f <> Op g = Op a -> f a <> g a
    
  • 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
    
  • Abelian a => Abelian (Op a b)Defined in groups-0.5.3 · Data.Group
  • Group a => Group (Op a b)Defined in groups-0.5.3 · Data.Group
  • type Rep (Op r) = rDefined in adjunctions-4.4.3 · Data.Functor.Contravariant.Rep
newtypenewtype Predicate a
#

Constructors

Instances12Contravariant, Decidable, Divisible, Conclude, Decide, Divise, …
  • Contravariant PredicateDefined in base-4.20.2.0 · Data.Functor.Contravariant

    A Predicate is a Contravariant Functor, because contramap can apply its function argument to the input of the predicate.

    Without newtypes contramap f equals precomposing with f (= (. f)).

    contramap :: (a' -> a) -> (Predicate a -> Predicate a')
    contramap f (Predicate g) = Predicate (g . f)
    
  • Decidable PredicateDefined in contravariant-1.5.5 · Data.Functor.Contravariant.Divisible
  • Divisible PredicateDefined in contravariant-1.5.5 · Data.Functor.Contravariant.Divisible
  • Conclude PredicateDefined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Conclude
  • Decide PredicateDefined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Decide
  • Divise PredicateDefined in semigroupoids-6.0.1 · Data.Functor.Contravariant.Divise
  • Representable PredicateDefined in adjunctions-4.4.3 · Data.Functor.Contravariant.Rep
  • Invariant PredicateDefined in invariant-0.6.4 · Data.Functor.Invariant

    from the contravariant package

  • Adjunction Predicate PredicateDefined in adjunctions-4.4.3 · Data.Functor.Contravariant.Adjunction

    This gives rise to the Cont Bool Monad

  • Semigroup (Predicate a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    (<>) on predicates uses logical conjunction (&&) on the results. Without newtypes this equals liftA2 (&&).

    (<>) :: Predicate a -> Predicate a -> Predicate a
    Predicate pred <> Predicate pred' = Predicate a ->
      pred a && pred' a
    
  • 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
    
  • type Rep Predicate = BoolDefined in adjunctions-4.4.3 · Data.Functor.Contravariant.Rep
datadata Arg a b
#

Arg isn't itself a Semigroup in its own right, but it can be placed inside Min and Max to compute an arg min or arg max.

Examples
Example1 expression
minimum [ Arg (x * x) x | x <- [-10 .. 10] ]Arg 0 0
Example1 expression
maximum [ Arg (-0.2*x^2 + 1.5*x + 1) x | x <- [-10 .. 10] ]Arg 3.8 4.0
Example1 expression
minimum [ Arg (-0.2*x^2 + 1.5*x + 1) x | x <- [-10 .. 10] ]Arg (-34.0) (-10.0)

Constructors

Instances35Bifoldable, Bifoldable1, Bifunctor, Bitraversable, NFData2, Biapplicative, …
typetype ArgMax a b = Max (Arg a b)
#
Examples
Example1 expression
Max (Arg 0 ()) <> Max (Arg 1 ())Max {getMax = Arg 1 ()}
Example1 expression
maximum [ Arg (length name) name | name <- ["violencia", "lea", "pixie"]]Arg 9 "violencia"
typetype ArgMin a b = Min (Arg a b)
#
Examples
Example1 expression
Min (Arg 0 ()) <> Min (Arg 1 ())Min {getMin = Arg 0 ()}
Example1 expression
minimum [ Arg (length name) name | name <- ["violencia", "lea", "pixie"]]Arg 3 "lea"
newtypenewtype First a
#

Beware that Data.Semigroup.First is different from Data.Monoid.First. The former simply returns the first value, so Data.Semigroup.First Nothing <> x = Data.Semigroup.First Nothing. The latter returns the first non-Nothing, thus Data.Monoid.First Nothing <> x = x.

Examples
Example1 expression
First 0 <> First 10First 0
Example1 expression
sconcat $ First 1 :| [ First n | n <- [2 ..] ]First 1

Constructors

Instances38Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
newtypenewtype Last a
#

Beware that Data.Semigroup.Last is different from Data.Monoid.Last. The former simply returns the last value, so x <> Data.Semigroup.Last Nothing = Data.Semigroup.Last Nothing. The latter returns the last non-Nothing, thus x <> Data.Monoid.Last Nothing = x.

Examples
Example1 expression
Last 0 <> Last 10Last {getLast = 10}
Example1 expression
sconcat $ Last 1 :| [ Last n | n <- [2..]]Last {getLast = * hangs forever *

Constructors

Instances38Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
newtypenewtype Max a
#

The Max Monoid and Semigroup always choose the bigger element as by the Ord instance and max of the contained type.

Examples
Example1 expression
Max 42 <> Max 3Max 42
Example1 expression
sconcat $ Max 1 :| [ Max n | n <- [2 .. 100]]Max {getMax = 100}

Constructors

Instances39Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
newtypenewtype Min a
#

The Min Monoid and Semigroup always choose the smaller element as by the Ord instance and min of the contained type.

Examples
Example1 expression
Min 42 <> Min 3Min 3
Example1 expression
sconcat $ Min 1 :| [ Min n | n <- [2 .. 100]]Min {getMin = 1}

Constructors

Instances39Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
newtypenewtype WrappedMonoid m
#

Provide a Semigroup for an arbitrary Monoid.

NOTE: This is not needed anymore since Semigroup became a superclass of Monoid in base-4.11 and this newtype be deprecated at some point in the future.

Constructors

Instances24NFData1, Copointed, Pointed, Generic1, Bounded, Enum, …
newtypenewtype WrappedBifunctor (p :: k -> k1 -> Type) (a :: k) (b :: k1)
#

Make a Functor over the second argument of a Bifunctor.

Constructors

Instances28Generic1, Bifoldable, Bifoldable1, Bifunctor, Bitraversable, Eq2, …
newtypenewtype ShortByteString
#

A compact representation of a Word8 vector.

It has a lower memory overhead than a ByteString and does not contribute to heap fragmentation. It can be converted to or from a ByteString (at the cost of copying the string data). It supports very few other operations.

Instances16IsList, Eq, Data, Ord, Read, Show, …
newtypenewtype Cokleisli (w :: k -> Type) (a :: k) b
#

The Cokleisli Arrows of a given Comonad

Constructors

Instances21Category, Semigroupoid, Ob, Arrow, ArrowApply, ArrowChoice, …
classclass Comonad w => ComonadApply (w :: Type -> Type) where
#

ComonadApply is to Comonad like Applicative is to Monad.

Mathematically, it is a strong lax symmetric semi-monoidal comonad on the category Hask of Haskell types. That it to say that w is a strong lax symmetric semi-monoidal functor on Hask, where both extract and duplicate are symmetric monoidal natural transformations.

Laws:

(.) <$> u <@> v <@> w = u <@> (v <@> w)
extract (p <@> q) = extract p (extract q)
duplicate (p <@> q) = (<@>) <$> duplicate p <@> duplicate q

If our type is both a ComonadApply and Applicative we further require

(<*>) = (<@>)

Finally, if you choose to define (<@) and (@>), the results of your definitions should match the following laws:

a @> b = const id <$> a <@> b
a <@ b = const <$> a <@> b

Methods

  • (<@>) :: w (a -> b) -> w a -> w binfixl 4
  • (@>) :: w a -> w b -> w binfixl 4
  • (<@) :: w a -> w b -> w ainfixl 4
Instances12ComonadApply, …
newtypenewtype Seq a
#

General-purpose finite sequences.

Instances49Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
  • Monad SeqDefined in containers-0.7 · Data.Sequence.Internal
  • Functor SeqDefined in containers-0.7 · Data.Sequence.Internal
  • MonadFix SeqDefined in containers-0.7 · Data.Sequence.Internal
  • Applicative SeqDefined in containers-0.7 · Data.Sequence.Internal
  • Foldable SeqDefined in containers-0.7 · Data.Sequence.Internal
  • Traversable SeqDefined in containers-0.7 · Data.Sequence.Internal
  • Alternative SeqDefined in containers-0.7 · Data.Sequence.Internal
  • MonadPlus SeqDefined in containers-0.7 · Data.Sequence.Internal
  • MonadZip SeqDefined in containers-0.7 · Data.Sequence.Internal
  • Eq1 SeqDefined in containers-0.7 · Data.Sequence.Internal
  • Ord1 SeqDefined in containers-0.7 · Data.Sequence.Internal
  • Read1 SeqDefined in containers-0.7 · Data.Sequence.Internal
  • Show1 SeqDefined in containers-0.7 · Data.Sequence.Internal
  • UnzipWith SeqDefined in containers-0.7 · Data.Sequence.Internal
  • Hashable1 SeqDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Alt SeqDefined in semigroupoids-6.0.1 · Data.Functor.Alt
  • Apply SeqDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Bind SeqDefined in semigroupoids-6.0.1 · Data.Functor.Bind.Class
  • Extend SeqDefined in semigroupoids-6.0.1 · Data.Functor.Extend
  • Plus SeqDefined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Invariant SeqDefined in invariant-0.6.4 · Data.Functor.Invariant

    from the containers package

  • Adjustable SeqDefined in keys-3.12.3 · Data.Key
  • FoldableWithKey SeqDefined in keys-3.12.3 · Data.Key
  • Indexable SeqDefined in keys-3.12.3 · Data.Key
  • Keyed SeqDefined in keys-3.12.3 · Data.Key
  • Lookup SeqDefined in keys-3.12.3 · Data.Key
  • TraversableWithKey SeqDefined in keys-3.12.3 · Data.Key
  • Zip SeqDefined in keys-3.12.3 · Data.Key
  • ZipWithKey SeqDefined in keys-3.12.3 · Data.Key
  • Pointed SeqDefined in pointed-5.0.4 · Data.Pointed
  • FoldableWithIndex Int SeqDefined in indexed-traversable-0.1.4 · WithIndex
  • FunctorWithIndex Int SeqDefined in indexed-traversable-0.1.4 · WithIndex

    The position in the Seq is available as the index.

  • TraversableWithIndex Int SeqDefined in indexed-traversable-0.1.4 · WithIndex
  • Lift a => Lift (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • IsList (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Eq a => Eq (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Data a => Data (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Ord a => Ord (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Read a => Read (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Show a => Show (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • a ~ Char => IsString (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Semigroup (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Monoid (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • NFData a => NFData (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Binary e => Binary (Seq e)Defined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable v => Hashable (Seq v)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Default (Seq a)Defined in data-default-0.8.0.1 · Data.Default.Internal
  • type Item (Seq a) = aDefined in containers-0.7 · Data.Sequence.Internal
  • type Key Seq = IntDefined in keys-3.12.3 · Data.Key
classclass Divisible f => Decidable (f :: Type -> Type) where
#

A Decidable contravariant functor is the contravariant analogue of Alternative.

Noting the superclass constraint that f must also be Divisible, a Decidable functor has the ability to "fan out" input, under the intuition that contravariant functors consume input.

In the discussion for Divisible, an example was demonstrated with Serializers, that turn as into ByteStrings. Divisible allowed us to serialize the product of multiple values by concatenation. By making our Serializer also Decidable- we now have the ability to serialize the sum of multiple values - for example different constructors in an ADT.

Consider serializing arbitrary identifiers that can be either Strings or Ints:

data Identifier = StringId String | IntId Int

We know we have serializers for Strings and Ints, but how do we combine them into a Serializer for Identifier? Essentially, our Serializer needs to scrutinise the incoming value and choose how to serialize it:

identifier :: Serializer Identifier
identifier = Serializer $ \identifier ->
  case identifier of
    StringId s -> runSerializer string s
    IntId i -> runSerializer int i

It is exactly this notion of choice that Decidable encodes. Hence if we add an instance of Decidable for Serializer...

instance Decidable Serializer where
  lose f = Serializer $ \a -> absurd (f a)
  choose split l r = Serializer $ \a ->
    either (runSerializer l) (runSerializer r) (split a)

Then our identifier Serializer is

identifier :: Serializer Identifier
identifier = choose toEither string int where
  toEither (StringId s) = Left s
  toEither (IntId i) = Right i

Methods

Instances27Decidable, …
classclass NFData a where
#

A class of types that can be fully evaluated.

Methods

  • rnf :: a -> ()

    rnf should reduce its argument to normal form (that is, fully evaluate all sub-components), and then return ().

    Generic NFData deriving

    Starting with GHC 7.2, you can automatically derive instances for types possessing a Generic instance.

    Note: Generic1 can be auto-derived starting with GHC 7.4

    {-# LANGUAGE DeriveGeneric #-}
    
    import GHC.Generics (Generic, Generic1)
    import Control.DeepSeq
    
    data Foo a = Foo a String
                 deriving (Eq, Generic, Generic1)
    
    instance NFData a => NFData (Foo a)
    instance NFData1 Foo
    
    data Colour = Red | Green | Blue
                  deriving Generic
    
    instance NFData Colour

    Starting with GHC 7.10, the example above can be written more concisely by enabling the new DeriveAnyClass extension:

    {-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
    
    import GHC.Generics (Generic)
    import Control.DeepSeq
    
    data Foo a = Foo a String
                 deriving (Eq, Generic, Generic1, NFData, NFData1)
    
    data Colour = Red | Green | Blue
                  deriving (Generic, NFData)
    
    Compatibility with previous deepseq versions

    Prior to version 1.4.0.0, the default implementation of the rnf method was defined as

    rnf a = seq a ()

    However, starting with deepseq-1.4.0.0, the default implementation is based on DefaultSignatures allowing for more accurate auto-derived NFData instances. If you need the previously used exact default rnf method implementation semantics, use

    instance NFData Colour where rnf x = seq x ()

    or alternatively

    instance NFData Colour where rnf = rwhnf

    or

    {-# LANGUAGE BangPatterns #-}
    instance NFData Colour where rnf !_ = ()
Instances186NFData, …
classclass (forall a. NFData a => NFData (f a)) => NFData1 (f :: Type -> Type) where
#

A class of functors that can be fully evaluated.

In `deepseq-1.5.0.0` this class was updated to include superclasses.

Methods

  • liftRnf :: (a -> ()) -> f a -> ()

    liftRnf should reduce its argument to normal form (that is, fully evaluate all sub-components), given an argument to reduce a arguments, and then return ().

    See rnf for the generic deriving.

Instances57NFData1, …
classclass (forall a. NFData a => NFData1 (p a)) => NFData2 (p :: Type -> Type -> Type) where
#

A class of bifunctors that can be fully evaluated.

In `deepseq-1.5.0.0` this class was updated to include superclasses.

Methods

  • liftRnf2 :: (a -> ()) -> (b -> ()) -> p a b -> ()

    liftRnf2 should reduce its argument to normal form (that is, fully evaluate all sub-components), given functions to reduce a and b arguments respectively, and then return ().

    Note: Unlike for the unary liftRnf, there is currently no support for generically deriving liftRnf2.

Instances17NFData2, …
classclass Applicative f => Alternative (f :: Type -> Type) where
#

A monoid on applicative functors.

If defined, some and many should be the least solutions of the equations:

Examples
Example1 expression
Nothing <|> Just 42Just 42
Example1 expression
[1, 2] <|> [3, 4][1,2,3,4]
Example1 expression
empty <|> print (2^15)32768

Methods

  • empty :: f a

    The identity of <|>

    empty <|> a     == a
    a     <|> empty == a
  • (<|>) :: f a -> f a -> f ainfixl 3

    An associative binary operation

  • some :: f a -> f [a]

    One or more.

    Examples
    Example1 expression
    some (putStr "la")lalalalalalalalala... * goes on forever *
    Example1 expression
    some Nothingnothing
    Example1 expression
    take 5 <$> some (Just 1)* hangs forever *

    Note that this function can be used with Parsers based on Applicatives. In that case some parser will attempt to parse parser one or more times until it fails.

  • many :: f a -> f [a]

    Zero or more.

    Examples
    Example1 expression
    many (putStr "la")lalalalalalalalala... * goes on forever *
    Example1 expression
    many NothingJust []
    Example1 expression
    take 5 <$> many (Just 1)* hangs forever *

    Note that this function can be used with Parsers based on Applicatives. In that case many parser will attempt to parse parser zero or more times until it fails.

Instances70Alternative, …
classclass (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) where
#

Monads that also support choice and failure.

Methods

  • mzero :: m a

    The identity of mplus. It should also satisfy the equations

    mzero >>= f  =  mzero
    v >> mzero   =  mzero

    The default definition is

    mzero = empty
    
  • mplus :: m a -> m a -> m a

    An associative operation. The default definition is

    mplus = (<|>)
    
Instances54MonadPlus, …
classclass Bits b => FiniteBits b where
#

The FiniteBits class denotes types with a finite, fixed number of bits.

Methods

Instances64FiniteBits, …
datadata BlockReason
#

Constructors

Instances3Eq, Ord, Show
  • Eq BlockReasonDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Ord BlockReasonDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Show BlockReasonDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
datadata ThreadId
#

A ThreadId is an abstract type representing a handle to a thread. ThreadId is an instance of Eq, Ord and Show, where the Ord instance implements an arbitrary total ordering over ThreadIds. The Show instance lets you convert an arbitrary-valued ThreadId to string form; showing a ThreadId value is occasionally useful when debugging or diagnosing the behaviour of a concurrent program.

Note: in GHC, if you have a ThreadId, you essentially have a pointer to the thread itself. This means the thread itself can't be garbage collected until you drop the ThreadId. This misfeature would be difficult to correct while continuing to support threadStatus.

Constructors

Instances5Eq, Ord, Show, NFData, Hashable
  • Eq ThreadIdDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Ord ThreadIdDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Show ThreadIdDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • NFData ThreadIdDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Hashable ThreadIdDefined in hashable-1.4.7.0 · Data.Hashable.Class
datadata ThreadStatus
#

The current status of a thread

Constructors

Instances3Eq, Ord, Show
classclass Arrow a => ArrowApply (a :: Type -> Type -> Type) where
#

Some arrows allow application of arrow inputs to other inputs. Instances should satisfy the following laws:

Such arrows are equivalent to monads (see ArrowMonad).

Methods

  • app :: a (a b c, b) c
Instances5ArrowApply
classclass Arrow a => ArrowChoice (a :: Type -> Type -> Type) where
#

Choice, for arrows that support it. This class underlies the if and case constructs in arrow notation.

Instances should satisfy the following laws:

where

assocsum (Left (Left x)) = Left x
assocsum (Left (Right y)) = Right (Left y)
assocsum (Right z) = Right (Right z)

The other combinators have sensible default definitions, which may be overridden for efficiency.

Methods

  • left :: a b c -> a (Either b d) (Either c d)

    Feed marked inputs through the argument arrow, passing the rest through unchanged to the output.

  • right :: a b c -> a (Either d b) (Either d c)

    A mirror image of left.

    The default definition may be overridden with a more efficient version if desired.

  • (+++) :: a b c -> a b' c' -> a (Either b b') (Either c c')infixr 2

    Split the input between the two argument arrows, retagging and merging their outputs. Note that this is in general not a functor.

    The default definition may be overridden with a more efficient version if desired.

  • (|||) :: a b d -> a c d -> a (Either b c) dinfixr 2

    Fanin: Split the input between the two argument arrows and merge their outputs.

    The default definition may be overridden with a more efficient version if desired.

Instances10ArrowChoice, …
classclass Arrow a => ArrowLoop (a :: Type -> Type -> Type) where
#

The loop operator expresses computations in which an output value is fed back as input, although the computation occurs only once. It underlies the rec value recursion construct in arrow notation. loop should satisfy the following laws:

extension

loop (arr f) = arr (\ b -> fst (fix (\ (c,d) -> f (b,d))))

left tightening

loop (first h >>> f) = h >>> loop f

right tightening

loop (f >>> first h) = loop f >>> h

sliding

loop (f >>> arr (id *** k)) = loop (arr (id *** k) >>> f)

vanishing

loop (loop f) = loop (arr unassoc >>> f >>> arr assoc)

superposing

second (loop f) = loop (arr assoc >>> second f >>> arr unassoc)

where

assoc ((a,b),c) = (a,(b,c))
unassoc (a,(b,c)) = ((a,b),c)

Methods

  • loop :: a (b, d) (c, d) -> a b c
Instances10ArrowLoop, …
newtypenewtype ArrowMonad (a :: Type -> Type -> Type) b
#

The ArrowApply class is equivalent to Monad: any monad gives rise to a Kleisli arrow, and any instance of ArrowApply defines a monad.

Constructors

Instances7Monad, Functor, Applicative, Alternative, MonadPlus, Invariant, …
classclass ArrowZero a => ArrowPlus (a :: Type -> Type -> Type) where
#

A monoid on arrows.

Methods

  • (<+>) :: a b c -> a b c -> a b cinfixr 5

    An associative operation with identity zeroArrow.

Instances8ArrowPlus, …
classclass Arrow a => ArrowZero (a :: Type -> Type -> Type) where
#

Methods

Instances9ArrowZero, …
newtypenewtype Kleisli (m :: Type -> Type) a b
#

Kleisli arrows of a monad.

Constructors

Instances30Category, Semigroupoid, Ob, Generic1, Arrow, ArrowApply, …
newtypenewtype NoMethodError
#

A class method without a definition (neither a default definition, nor a definition in the appropriate instance) was called. The String gives information about which method it was.

Constructors

Instances2Show, Exception
datadata NonTermination
#

Thrown when the runtime system detects that the computation is guaranteed not to terminate. Note that there is no guarantee that the runtime system will notice whether any given computation is guaranteed to terminate or not.

Instances2Show, Exception
newtypenewtype RecConError
#

An uninitialised record field was used. The String gives information about the source location where the record was constructed.

Constructors

Instances2Show, Exception
  • Show RecConErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Exception RecConErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
newtypenewtype RecSelError
#

A record selector was applied to a constructor without the appropriate field. This can only happen with a datatype with multiple constructors, where some fields are in one constructor but not another. The String gives information about the source location of the record selector.

Constructors

Instances2Show, Exception
  • Show RecSelErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Exception RecSelErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
newtypenewtype RecUpdError
#

A record update was performed on a constructor without the appropriate field. This can only happen with a datatype with multiple constructors, where some fields are in one constructor but not another. The String gives information about the source location of the record update.

Constructors

Instances2Show, Exception
  • Show RecUpdErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Exception RecUpdErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
newtypenewtype TypeError
#

An expression that didn't typecheck during compile time was called. This is only possible with -fdefer-type-errors. The String gives details about the failed type check.

Constructors

Instances2Show, Exception
  • Show TypeErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Exception TypeErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
newtypenewtype And a
#

Monoid under bitwise AND.

Example1 expression
getAnd (And 0xab <> And 0x12) :: Word82

Constructors

Instances9Bounded, Enum, Eq, Read, Show, Semigroup, …
  • Bounded a => Bounded (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Enum a => Enum (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Eq a => Eq (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Bits a => Semigroup (And 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.

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

Monoid under bitwise 'equality'; defined as 1 if the corresponding bits match, and 0 otherwise.

Example1 expression
getIff (Iff 0xab <> Iff 0x12) :: Word870

Constructors

Instances9Bounded, Enum, Eq, Read, Show, Semigroup, …
  • Bounded a => Bounded (Iff 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
  • Eq a => Eq (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • FiniteBits a => Semigroup (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.

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

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

Monoid under bitwise inclusive OR.

Example1 expression
getIor (Ior 0xab <> Ior 0x12) :: Word8187

Constructors

Instances9Bounded, Enum, Eq, Read, Show, Semigroup, …
  • Bounded a => Bounded (Ior 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
  • Eq a => Eq (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Bits a => Semigroup (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Bits a => Monoid (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Bits a => Bits (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • FiniteBits a => FiniteBits (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
newtypenewtype Xor a
#

Monoid under bitwise XOR.

Example1 expression
getXor (Xor 0xab <> Xor 0x12) :: Word8185

Constructors

Instances9Bounded, Enum, Eq, Read, Show, Semigroup, …
  • Bounded a => Bounded (Xor 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
  • Eq a => Eq (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Bits a => Semigroup (Xor 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
  • Bits a => Bits (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • FiniteBits a => FiniteBits (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
typetype ConIndex = Int
#

Unique index for datatype constructors, counting from 1 in the order they are given in the program text.

datadata Constr
#

Representation of constructors. Note that equality on constructors with different types may not work -- i.e. the constructors for False and Nothing may compare equal.

Instances2Eq, Show
  • Eq ConstrDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data

    Equality of constructors

  • Show ConstrDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
datadata DataType
#

Representation of datatypes. A package of constructor representations with names of type and module.

Instances1Show
  • Show DataTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
datadata Fixity
#

Fixity of constructors

Instances2Eq, Show
  • Eq FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Show FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
newtypenewtype Const a (b :: k)
#

The Const functor.

Examples
Example1 expression
fmap (++ "World") (Const "Hello")Const "Hello"

Because we ignore the second type parameter to Const, the Applicative instance, which has (<*>) :: Monoid m => Const m (a -> b) -> Const m a -> Const m b essentially turns into Monoid m => m -> m -> m, which is (<>)

Example1 expression
Const [1, 2, 3] <*> Const [4, 5, 6]Const [1,2,3,4,5,6]

Constructors

Instances81Semigroupoid, Generic1, FoldableWithIndex, FunctorWithIndex, TraversableWithIndex, Bifoldable, …
newtypenewtype Ap (f :: k -> Type) (a :: k)
#

This data type witnesses the lifting of a Monoid into an Applicative pointwise.

Examples
Example1 expression
Ap (Just [1, 2, 3]) <> Ap NothingAp {getAp = Nothing}
Example1 expression
Ap [Sum 10, Sum 20] <> Ap [Sum 1, Sum 2]Ap {getAp = [Sum {getSum = 11},Sum {getSum = 12},Sum {getSum = 21},Sum {getSum = 22}]}

Constructors

Instances24Generic1, Monad, Functor, MonadFix, MonadFail, Applicative, …
  • Generic1 (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monad f => Monad (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Functor f => Functor (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • MonadFix f => MonadFix (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Monad.Fix
  • MonadFail f => MonadFail (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Applicative f => Applicative (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Foldable f => Foldable (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Foldable
  • Traversable f => Traversable (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Traversable
  • Alternative f => Alternative (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • MonadPlus f => MonadPlus (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Foldable1 f => Foldable1 (Ap f)Defined in base-4.20.2.0 · Data.Foldable1
  • (Applicative f, Bounded a) => Bounded (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Enum (f a) => Enum (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Eq (f a) => Eq (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • (Data (f a), Data a, Typeable f) => Data (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • (Applicative f, Num a) => Num (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid

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

    Commutativity:

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

    Additive inverse:

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

    Distributivity:

    Example2 expressions
    Ap [1,2] * (3 + 4)Ap {getAp = [7,14]}(Ap [1,2] * 3) + (Ap [1,2] * 4)Ap {getAp = [7,11,10,14]}
  • Ord (f a) => Ord (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Read (f a) => Read (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Show (f a) => Show (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Generic (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • (Applicative f, Semigroup a) => Semigroup (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • (Applicative f, Monoid a) => Monoid (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • type Rep (Ap f a) = D1 ('MetaData "Ap" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "Ap" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a))))Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • type Rep1 (Ap f) = D1 ('MetaData "Ap" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "Ap" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)))Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
newtypenewtype Down a
#

The Down type allows you to reverse sort order conveniently. A value of type Down a contains a value of type a (represented as Down a).

If a has an Ord instance associated with it then comparing two values thus wrapped will give you the opposite of their normal sort order. This is particularly useful when sorting in generalised list comprehensions, as in: then sortWith by Down x.

Example1 expression
compare True FalseGT
Example1 expression
compare (Down True) (Down False)LT

If a has a Bounded instance then the wrapped instance also respects the reversed ordering by exchanging the values of minBound and maxBound.

Example1 expression
minBound :: Int-9223372036854775808
Example1 expression
minBound :: Down IntDown 9223372036854775807

All other instances of Down a behave as they do for a.

Constructors

Instances48Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
datadata KProxy t
#

A concrete, promotable proxy type, for use at the kind level. There are no instances for this because it is intended at the kind level only

newtypenewtype All
#

Boolean monoid under conjunction (&&).

All x <> All y = All (x && y)
Examples
Example1 expression
All True <> mempty <> All False)All {getAll = False}
Example1 expression
mconcat (map (\x -> All (even x)) [2,4,6,7,8])All {getAll = False}
Example1 expression
All True <> memptyAll {getAll = True}

Constructors

Instances18Bounded, Eq, Data, Ord, Read, Show, …
  • Bounded AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Eq AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Data AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Ord AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Generic AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Semigroup AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • NFData AllDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Binary AllDefined in binary-0.8.9.3 · Data.Binary.Class
  • Unbox AllDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Default AllDefined in data-default-0.8.0.1 · Data.Default.Internal
  • Vector Vector AllDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector AllDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • type Rep All = D1 ('MetaData "All" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "All" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAll") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • data MVector s AllDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector AllDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
newtypenewtype Any
#

Boolean monoid under disjunction (||).

Any x <> Any y = Any (x || y)
Examples
Example1 expression
Any True <> mempty <> Any FalseAny {getAny = True}
Example1 expression
mconcat (map (\x -> Any (even x)) [2,4,6,7,8])Any {getAny = True}
Example1 expression
Any False <> memptyAny {getAny = False}

Constructors

Instances18Bounded, Eq, Data, Ord, Read, Show, …
  • Bounded AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Eq AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Data AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Ord AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Generic AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Semigroup AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • NFData AnyDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Binary AnyDefined in binary-0.8.9.3 · Data.Binary.Class
  • Unbox AnyDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Default AnyDefined in data-default-0.8.0.1 · Data.Default.Internal
  • Vector Vector AnyDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector AnyDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • type Rep Any = D1 ('MetaData "Any" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Any" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAny") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • data MVector s AnyDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector AnyDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
newtypenewtype Endo a
#

The monoid of endomorphisms under composition.

Endo f <> Endo g == Endo (f . g)
Examples
Example2 expressions
let computation = Endo ("Hello, " ++) <> Endo (++ "!")appEndo computation "Haskell""Hello, Haskell!"
Example2 expressions
let computation = Endo (*3) <> Endo (+1)appEndo computation 16

Constructors

Instances7Invariant, Pointed, Generic, Semigroup, Monoid, Default, …
datadata (:~:) (a :: k) (b :: k) where
#

Propositional equality. If a :~: b is inhabited by some terminating value, then the type a is the same as the type b. To use this equality in practice, pattern-match on the a :~: b to get out the Refl constructor; in the body of the pattern-match, the compiler knows that a ~ b.

Constructors

Instances15Category, Groupoid, Semigroupoid, TestCoercion, TestEquality, NFData2, …
  • Category (:~:)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Category
  • Groupoid (:~:)Defined in semigroupoids-6.0.1 · Data.Groupoid
  • Semigroupoid (:~:)Defined in semigroupoids-6.0.1 · Data.Semigroupoid
  • TestCoercion ((:~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • TestEquality ((:~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • NFData2 (:~:)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • NFData1 ((:~:) a)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • a ~ b => Bounded (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
  • Eq (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • (a ~ b, Data a) => Data (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Ord (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • a ~ b => Read (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Show (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • NFData (a :~: b)Defined in deepseq-1.5.0.0 · Control.DeepSeq
datadata (:~~:) (a :: k1) (b :: k2) where
#

Kind heterogeneous propositional equality. Like :~:, a :~~: b is inhabited by a terminating value if and only if a is the same type as b.

Constructors

Instances15Category, Groupoid, Semigroupoid, TestCoercion, TestEquality, NFData2, …
  • Category (:~~:)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Category
  • Groupoid (:~~:)Defined in semigroupoids-6.0.1 · Data.Groupoid
  • Semigroupoid (:~~:)Defined in semigroupoids-6.0.1 · Data.Semigroupoid
  • TestCoercion ((:~~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • TestEquality ((:~~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • NFData2 (:~~:)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • NFData1 ((:~~:) a)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • a ~~ b => Bounded (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
  • Eq (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • (Typeable i, Typeable j, Typeable a, Typeable b, a ~~ b) => Data (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Ord (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • a ~~ b => Read (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Show (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • NFData (a :~~: b)Defined in deepseq-1.5.0.0 · Control.DeepSeq
typetype TypeRep = SomeTypeRep
#

A quantified type representation.

Instances1NFData
  • NFData TypeRepDefined in deepseq-1.5.0.0 · Control.DeepSeq

    NOTE: Prior to deepseq-1.4.4.0 this instance was only defined for base-4.8.0.0 and later.

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

Instances110Bounded, …
datadata ErrorCall
#

This is thrown when the user calls error. The first String is the argument given to error, second String is the location.

Instances4Eq, Ord, Show, Exception
  • Eq ErrorCallDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception
  • Ord ErrorCallDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception
  • Show ErrorCallDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception
  • Exception ErrorCallDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception
classclass Fractional a => Floating a where
#

Trigonometric and hyperbolic functions and related functions.

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

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

  • exp (fromInteger 0) = fromInteger 1

Methods

  • pi :: a
  • exp :: a -> a
  • log :: a -> a
  • sqrt :: a -> a
  • (**) :: a -> a -> ainfixr 8
  • logBase :: a -> a -> a
  • sin :: a -> a
  • cos :: a -> a
  • tan :: a -> a
  • asin :: a -> a
  • acos :: a -> a
  • atan :: a -> a
  • sinh :: a -> a
  • cosh :: a -> a
  • tanh :: a -> a
  • asinh :: a -> a
  • acosh :: a -> a
  • atanh :: a -> a
  • log1p :: a -> a

    log1p x computes log (1 + x), but provides more precise results for small (absolute) values of x if possible.

  • expm1 :: a -> a

    expm1 x computes exp x - 1, but provides more precise results for small (absolute) values of x if possible.

  • log1pexp :: a -> a

    log1pexp x computes log (1 + exp x), but provides more precise results if possible.

    Examples:

    • if x is a large negative number, log (1 + exp x) will be imprecise for the reasons given in log1p.

    • if exp x is close to -1, log (1 + exp x) will be imprecise for the reasons given in expm1.

  • log1mexp :: a -> a

    log1mexp x computes log (1 - exp x), but provides more precise results if possible.

    Examples:

    • if x is a large negative number, log (1 - exp x) will be imprecise for the reasons given in log1p.

    • if exp x is close to 1, log (1 - exp x) will be imprecise for the reasons given in expm1.

Instances11Floating, …
newtypenewtype IntPtr
#

A signed integral type that can be losslessly converted to and from Ptr. This type is also compatible with the C99 type intptr_t, and can be marshalled to and from that type safely.

Constructors

Instances17Bounded, Enum, Eq, Integral, Data, Num, …
  • Bounded IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Enum IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Eq IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Integral IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Data IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Ord IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Read IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Real IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Show IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Ix IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Bits IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • FiniteBits IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Storable IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Hashable IntPtrDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Prim IntPtrDefined in primitive-0.9.1.0 · Data.Primitive.Types
  • Default IntPtrDefined in data-default-0.8.0.1 · Data.Default.Internal
newtypenewtype WordPtr
#

An unsigned integral type that can be losslessly converted to and from Ptr. This type is also compatible with the C99 type uintptr_t, and can be marshalled to and from that type safely.

Constructors

Instances17Bounded, Enum, Eq, Integral, Data, Num, …
  • Bounded WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Enum WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Eq WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Integral WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Data WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Ord WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Read WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Real WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Show WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Ix WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Bits WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • FiniteBits WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Storable WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Hashable WordPtrDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Prim WordPtrDefined in primitive-0.9.1.0 · Data.Primitive.Types
  • Default WordPtrDefined in data-default-0.8.0.1 · Data.Default.Internal
typetype FinalizerPtr a = FunPtr (Ptr a -> IO ())
#

A finalizer is represented as a pointer to a foreign function that, at finalisation time, gets as an argument a plain pointer variant of the foreign pointer that the finalizer is associated with.

Note that the foreign function must either use the ccall or the capi calling convention.

newtypenewtype ZipList a
#

Lists, but with an Applicative functor based on zipping.

Examples

In contrast to the Applicative for GHC.List.List:

Example1 expression
(+) <$> [1, 2, 3] <*> [4, 5, 6][5,6,7,6,7,8,7,8,9]

The Applicative instance of ZipList applies the operation by pairing up the elements, analogous to zipWithN

Example1 expression
(+) <$> ZipList [1, 2, 3] <*> ZipList [4, 5, 6]ZipList {getZipList = [5,7,9]}
Example1 expression
(,,,) <$> ZipList [1, 2] <*> ZipList [3, 4] <*> ZipList [5, 6] <*> ZipList [7, 8]ZipList {getZipList = [(1,3,5,7),(2,4,6,8)]}
Example1 expression
ZipList [(+1), (^2), (/ 2)] <*> ZipList [5, 5, 5]ZipList {getZipList = [6.0,25.0,2.5]}

Constructors

Instances34Functor, Applicative, Foldable, Traversable, Alternative, NFData1, …
typetype FilePath = String
#

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

datadata MaskingState
#

Describes the behaviour of a thread when an asynchronous exception is received.

Constructors

Instances3Eq, Show, NFData
datadata ArrayException
#

Exceptions generated by array operations

Constructors

Instances4Eq, Ord, Show, Exception
datadata AsyncException
#

Asynchronous exceptions.

Constructors

  • StackOverflow

    The current thread's stack exceeded its limit. Since an exception has been raised, the thread's stack will certainly be below its limit again, but the programmer should take remedial action immediately.

  • HeapOverflow

    The program's heap is reaching its limit, and the program should take action to reduce the amount of live data it has. Notes:

    • It is undefined which thread receives this exception. GHC currently throws this to the same thread that receives UserInterrupt, but this may change in the future.

    • The GHC RTS currently can only recover from heap overflow if it detects that an explicit memory limit (set via RTS flags). has been exceeded. Currently, failure to allocate memory from the operating system results in immediate termination of the program.

  • ThreadKilled

    This exception is raised by another thread calling killThread, or by the system if it needs to terminate the thread for some reason.

  • UserInterrupt

    This exception is raised by default in the main thread of the program when the user requests to terminate the program via the usual mechanism(s) (e.g. Control-C in the console).

Instances4Eq, Ord, Show, Exception
datadata Deadlock
#

There are no runnable threads, so the program is deadlocked. The Deadlock exception is raised in the main thread only.

Instances2Show, Exception
  • Show DeadlockDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Exception DeadlockDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
datadata ExitCode
#

Defines the exit codes that a program can return.

Constructors

  • ExitSuccess

    indicates successful termination;

  • ExitFailure Int

    indicates program failure with an exit code. The exact interpretation of the code is operating-system dependent. In particular, some values may be prohibited (e.g. 0 on a POSIX-compliant system).

Instances8Eq, Ord, Read, Show, Generic, Exception, …
typetype IOError = IOException
#

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

In Haskell 2010, this is an opaque type.

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.

Constructors

Instances4Eq, Show, Exception, MonadError
datadata IOErrorType
#
Instances2Eq, Show
  • Eq IOErrorTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show IOErrorTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
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.

Instances29IsList, …
  • IsList ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • IsList BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.Internal

    For long or infinite lists use fromList because it uses LazyByteString otherwise use fromListN which uses StrictByteString.

  • IsList ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • IsList ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • IsList ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • IsList IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • 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.

  • IsList TextDefined in text-2.1.3 · Data.Text · orphan

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedLists['\55555'] :: Text"\65533"
  • IsList TextDefined in text-2.1.3 · Data.Text.Lazy · orphan

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedLists['\55555'] :: Data.Text.Lazy.Text"\65533"
  • Storable a => IsList (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Storable
  • IsList (IntMap a)Defined in containers-0.7 · Data.IntMap.Internal
  • IsList (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • IsList (DNonEmpty a)Defined in dlist-1.0 · Data.DList.DNonEmpty.Internal
  • IsList (DList a)Defined in dlist-1.0 · Data.DList.Internal
  • 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 (Array a)Defined in primitive-0.9.1.0 · Data.Primitive.Array
  • IsList (SmallArray a)Defined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • IsList (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • IsList (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Strict
  • IsList [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.IsList
  • Ord a => IsList (Set a)Defined in containers-0.7 · Data.Set.Internal
  • Hashable a => IsList (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Prim a => IsList (PrimArray a)Defined in primitive-0.9.1.0 · Data.Primitive.PrimArray
  • Prim a => IsList (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Primitive
  • Unbox e => IsList (Vector e)Defined in vector-0.13.2.0 · Data.Vector.Unboxed · orphan
  • Ord k => IsList (Map k v)Defined in containers-0.7 · Data.Map.Internal
  • Hashable k => IsList (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
familytype family Item l
#

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

Instances29Item, …
  • type Item ByteArray = Word8Defined in base-4.20.2.0 · Data.Array.Byte
  • type Item Builder = Word8Defined in bytestring-0.12.2.0 · Data.ByteString.Builder.Internal
  • type Item ByteString = Word8Defined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • type Item ByteString = Word8Defined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • type Item ShortByteString = Word8Defined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • type Item IntSet = KeyDefined in containers-0.7 · Data.IntSet.Internal
  • type Item Version = IntDefined in ghc-internal-9.1003.0 · GHC.Internal.IsList
  • type Item CallStack = (String, SrcLoc)Defined in ghc-internal-9.1003.0 · GHC.Internal.IsList
  • type Item Text = CharDefined in text-2.1.3 · Data.Text · orphan
  • type Item Text = CharDefined in text-2.1.3 · Data.Text.Lazy · orphan
  • type Item (IntMap a) = (Key, a)Defined in containers-0.7 · Data.IntMap.Internal
  • type Item (Map k v) = (k, v)Defined in containers-0.7 · Data.Map.Internal
  • type Item (Seq a) = aDefined in containers-0.7 · Data.Sequence.Internal
  • type Item (Set a) = aDefined in containers-0.7 · Data.Set.Internal
  • type Item (DNonEmpty a) = aDefined in dlist-1.0 · Data.DList.DNonEmpty.Internal
  • type Item (DList a) = aDefined in dlist-1.0 · Data.DList.Internal
  • type Item (NonEmpty a) = aDefined in ghc-internal-9.1003.0 · GHC.Internal.IsList
  • type Item (ZipList a) = aDefined in ghc-internal-9.1003.0 · GHC.Internal.IsList
  • type Item (Array a) = aDefined in primitive-0.9.1.0 · Data.Primitive.Array
  • type Item (PrimArray a) = aDefined in primitive-0.9.1.0 · Data.Primitive.PrimArray
  • type Item (SmallArray a) = aDefined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • type Item (HashMap k v) = (k, v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • type Item (HashSet a) = aDefined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • type Item (Vector a) = aDefined in vector-0.13.2.0 · Data.Vector
  • type Item (Vector a) = aDefined in vector-0.13.2.0 · Data.Vector.Primitive
  • type Item (Vector a) = aDefined in vector-0.13.2.0 · Data.Vector.Storable
  • type Item (Vector a) = aDefined in vector-0.13.2.0 · Data.Vector.Strict
  • type Item (Vector e) = eDefined in vector-0.13.2.0 · Data.Vector.Unboxed · orphan
  • type Item [a] = aDefined in ghc-internal-9.1003.0 · GHC.Internal.IsList
classclass Num a => Fractional a where
#

Fractional numbers, supporting real division.

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

recip gives the multiplicative inverse

x * recip x

=

recip x * x

=

fromInteger 1

Totality of toRational

toRational

is total

Coherence with toRational

if the type also implements

Real

, then

fromRational

is a left inverse for

toRational

, i.e.

fromRational (toRational i) = i

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

Methods

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

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

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

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

    Example4 expressions
    0 == (-0 :: Float)Truerecip 0 == recip (-0 :: Float)Falsemap (/ 0) [-1, 0, 1 :: Float][-Infinity,NaN,Infinity]map (* 0) $ map (/ 0) [-1, 0, 1 :: Float][NaN,NaN,NaN]
  • Fractional ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    WARNING: recip and / will throw an error when their outputs are repeating decimals.

    These methods also compute Integer magnitudes (10^e). If these methods are applied to arguments which have huge exponents this could fill up all space and crash your program! So don't apply these methods to scientific numbers coming from untrusted sources.

    fromRational will throw an error when the input Rational is a repeating decimal. Consider using fromRationalRepetend for these rationals which will detect the repetition and indicate where it starts.

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

Integral numbers, supporting integer division.

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

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

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

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

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

Methods

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

    Integer division truncated toward zero.

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

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

    Integer remainder, satisfying

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

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

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

    Integer division truncated toward negative infinity.

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

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

    Integer modulus, satisfying

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

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

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

    Simultaneous quot and rem.

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

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

    simultaneous div and mod.

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

  • toInteger :: a -> Integer

    Conversion to Integer.

Instances61Integral, …
  • Integral IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Integral WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Integral Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral CardinalityDefined in random-1.2.1.3 · System.Random.GFinite
  • Integral I8Defined in text-2.1.3 · Data.Text.Foreign
  • Integral a => Integral (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Integral a => Integral (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Integral a => Integral (Tagged s a)Defined in tagged-0.8.9 · Data.Tagged
  • Integral (f (g a)) => Integral (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
classclass (Real a, Fractional a) => RealFrac a where
#

Extracting components of fractions.

Methods

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

    Beware that results for non-finite arguments are garbage:

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

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

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

    Beware that results for non-finite arguments are garbage:

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

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

  • RealFrac ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    WARNING: the methods of the RealFrac instance need to compute the magnitude 10^e. If applied to a huge exponent this could take a long time. Even worse, when the destination type is unbounded (i.e. Integer) it could fill up all space and crash your program!

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

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

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

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

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

classclass Group g => Abelian g
#

An Abelian group is a Group that follows the rule:

a <> b == b <> a
Instances16Abelian, …
classclass Group a => Cyclic a where
#

A Group G is Cyclic if there exists an element x of G such that for all y in G, there exists an n, such that

y = pow x n

Methods

Instances6Cyclic
datadata Hashed a
#

A hashable value along with the result of the hash function.

Instances11Foldable, Eq1, Ord1, Show1, Hashable1, Eq, …
  • Foldable HashedDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Eq1 HashedDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Ord1 HashedDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Show1 HashedDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Hashable1 HashedDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Eq a => Eq (Hashed a)Defined in hashable-1.4.7.0 · Data.Hashable.Class

    Uses precomputed hash to detect inequality faster

  • Ord a => Ord (Hashed a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Show a => Show (Hashed a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • (IsString a, Hashable a) => IsString (Hashed a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • NFData a => NFData (Hashed a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Eq a => Hashable (Hashed a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
classclass Invariant2 (f :: Type -> Type -> Type) where
#

Any * -> * -> * type parametric in both arguments permits an instance of Invariant2.

Instances should satisfy the following laws:

invmap2 id id id id = id
invmap2 f2 f2' g2 g2' . invmap2 f1 f1' g1 g1' =
  invmap2 (f2 . f1) (f1' . f2') (g2 . g1) (g1' . g2')

Methods

  • invmap2 :: (a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> f a b -> f c d
Instances49Invariant2, …
newtypenewtype WrappedContravariant (f :: k -> Type) (a :: k)
#

Wrap a Contravariant functor to be used as a member of Invariant.

Instances8Contravariant, Decidable, Divisible, Invariant, Eq, Ord, …
newtypenewtype WrappedFunctor (f :: k -> Type) (a :: k)
#

Wrap a Functor to be used as a member of Invariant.

Constructors

Instances12Monad, Functor, Applicative, Foldable, Traversable, Alternative, …
newtypenewtype WrappedProfunctor (p :: k -> k1 -> Type) (a :: k) (b :: k1)
#

Wrap a Profunctor to be used as a member of Invariant2.

Constructors

Instances23ProfunctorFunctor, Category, ProfunctorComonad, ProfunctorMonad, Arrow, ArrowChoice, …
classclass Monad m => MonadCont (m :: Type -> Type) where
#

Methods

  • callCC :: ((a -> m b) -> m a) -> m a

    callCC (call-with-current-continuation) calls a function with the current continuation as its argument. Provides an escape continuation mechanism for use with Continuation monads. Escape continuations allow to abort the current computation and return a value immediately. They achieve a similar effect to throwError and catchError within an Except monad. Advantage of this function over calling return is that it makes the continuation explicit, allowing more flexibility and better control (see examples in Control.Monad.Cont).

    The standard idiom used with callCC is to provide a lambda-expression to name the continuation. Then calling the named continuation anywhere within its scope will escape from the computation, even if it is many layers deep within nested computations.

Instances22MonadCont, …
classclass Monad m => MonadError e (m :: Type -> Type) | m -> e where
#

The strategy of combining computations that can throw exceptions by bypassing bound functions from the point an exception is thrown to the point that it is handled.

Is parameterized over the type of error information and the monad type constructor. It is common to use Either String as the monad type constructor for an error monad in which error descriptions take the form of strings. In that case and many other common cases the resulting monad is already defined as an instance of the MonadError class. You can also define your own error type and/or use a monad type constructor other than Either String or Either IOError. In these cases you will have to explicitly define instances of the MonadError class. (If you are using the deprecated Control.Monad.Error or Control.Monad.Trans.Error, you may also have to define an Error instance.)

Methods

  • throwError :: e -> m a

    Is used within a monadic computation to begin exception processing.

  • catchError :: m a -> (e -> m a) -> m a

    A handler function to handle previous errors and return to normal execution. A common idiom is:

    do { action1; action2; action3 } `catchError` handler

    where the action functions can call throwError. Note that handler and the do-block must have the same return type.

Instances23MonadError, …
classclass Monad m => MonadReader r (m :: Type -> Type) | m -> r where
#

See examples in Control.Monad.Reader. Note, the partially applied function type (->) r is a simple reader monad. See the instance declaration below.

Methods

  • ask :: m r

    Retrieves the monad environment.

  • local :: (r -> r) -> m a -> m a

    Executes a computation in a modified environment.

  • reader :: (r -> a) -> m a

    Retrieves a function of the current environment.

Instances29MonadReader, …
classclass Monad m => MonadState s (m :: Type -> Type) | m -> s where
#

Minimal definition is either both of get and put or just state

Methods

  • get :: m s

    Return the state from the internals of the monad.

  • put :: s -> m ()

    Replace the state inside the monad.

  • state :: (s -> (a, s)) -> m a

    Embed a simple state action into the monad.

Instances26MonadState, …
classclass (Monoid w, Monad m) => MonadWriter w (m :: Type -> Type) | m -> w where
#

Methods

  • writer :: (a, w) -> m a

    writer (a,w) embeds a simple writer action.

  • tell :: w -> m ()

    tell w is an action that produces the output w.

  • listen :: m a -> m (a, w)

    listen m is an action that executes the action m and adds its output to the value of the computation.

  • pass :: m (a, w -> w) -> m a

    pass m is an action that executes the action m, which returns a value and a function, and returns the value, applying the function to the output.

Instances25MonadWriter, …
classclass Profunctor p => Cochoice (p :: Type -> Type -> Type) where
#

Methods

Instances13Cochoice, …
newtypenewtype CopastroSum (p :: Type -> Type -> Type) a b
#

CopastroSum -| CotambaraSum

CopastroSum freely constructs costrength with respect to Either (aka Choice)

Constructors

Instances8ProfunctorMonad, ProfunctorAdjunction, ProfunctorFunctor, Cochoice, Profunctor, Invariant2, …
datadata CotambaraSum (q :: Type -> Type -> Type) a b where
#

CotambaraSum cofreely constructs costrength with respect to Either (aka Choice)

Constructors

Instances8ProfunctorComonad, ProfunctorAdjunction, ProfunctorFunctor, Cochoice, Profunctor, Invariant2, …
datadata PastroSum (p :: Type -> Type -> Type) a b where
#

PastroSum -| TambaraSum

PastroSum freely constructs strength with respect to Either.

Constructors

Instances8ProfunctorMonad, ProfunctorAdjunction, ProfunctorFunctor, Choice, Profunctor, Invariant2, …
newtypenewtype TambaraSum (p :: Type -> Type -> Type) a b
#

TambaraSum is cofreely adjoins strength with respect to Either.

Note: this is not dual to Data.Profunctor.Tambara.Tambara. It is Data.Profunctor.Tambara.Tambara with respect to a different tensor.

Constructors

Instances9ProfunctorComonad, ProfunctorAdjunction, ProfunctorFunctor, Category, Choice, Profunctor, …
newtypenewtype Closure (p :: Type -> Type -> Type) a b
#

Closure adjoins a Closed structure to any Profunctor.

Analogous to Data.Profunctor.Tambara.Tambara for Strong.

Constructors

Instances18ProfunctorComonad, ProfunctorAdjunction, ProfunctorFunctor, Category, Arrow, ArrowLoop, …
datadata Procompose (p :: k -> k1 -> Type) (q :: k2 -> k -> Type) (d :: k2) (c :: k1) where
#

Procompose p q is the Profunctor composition of the Profunctors p and q.

For a good explanation of Profunctor composition in Haskell see Dan Piponi's article:

http://blog.sigfpe.com/2011/07/profunctors-in-haskell.html

Procompose has a polymorphic kind since 5.6.

Constructors

Instances19ProfunctorFunctor, ProfunctorMonad, ProfunctorAdjunction, Choice, Closed, Mapping, …
newtypenewtype Rift (p :: k -> k1 -> Type) (q :: k2 -> k1 -> Type) (a :: k2) (b :: k)
#

This represents the right Kan lift of a Profunctor q along a Profunctor p in a limited version of the 2-category of Profunctors where the only object is the category Hask, 1-morphisms are profunctors composed and compose with Profunctor composition, and 2-morphisms are just natural transformations.

Rift has a polymorphic kind since 5.6.

Constructors

Instances8ProfunctorFunctor, Category, ProfunctorComonad, ProfunctorAdjunction, Profunctor, Invariant2, …
newtypenewtype CofreeMapping (p :: Type -> Type -> Type) a b
#

Constructors

Instances9ProfunctorComonad, ProfunctorFunctor, Choice, Closed, Mapping, Strong, …
datadata FreeMapping (p :: Type -> Type -> Type) a b where
#
FreeMapping -| CofreeMapping

Constructors

Instances11ProfunctorMonad, ProfunctorFunctor, Choice, Closed, Mapping, Strong, …
classclass ProfunctorFunctor t => ProfunctorComonad (t :: (Type -> Type -> Type) -> Type -> Type -> Type) where
#
Instances15ProfunctorComonad, …
classclass ProfunctorFunctor (t :: (Type -> Type -> Type) -> k -> k1 -> Type) where
#

ProfunctorFunctor has a polymorphic kind since 5.6.

Methods

Instances24ProfunctorFunctor, …
classclass ProfunctorFunctor t => ProfunctorMonad (t :: (Type -> Type -> Type) -> Type -> Type -> Type) where
#
Instances14ProfunctorMonad, …
newtypenewtype Codensity (p :: k -> k1 -> Type) (a :: k1) (b :: k1)
#

This represents the right Kan extension of a Profunctor p along itself. This provides a generalization of the "difference list" trick to profunctors.

Codensity has a polymorphic kind since 5.6.

Constructors

Instances5Category, Profunctor, Invariant2, Functor, Invariant
classclass (Cosieve p (Corep p), Costrong p) => Corepresentable (p :: Type -> Type -> Type) where
#

A Profunctor p is Corepresentable if there exists a Functor f such that p d c is isomorphic to f d -> c.

Associated types

Methods

Instances5Corepresentable
familytype family Corep (p :: Type -> Type -> Type) :: Type -> Type
#
Instances5Corep
datadata Prep (p :: Type -> k -> Type) (a :: k) where
#
Prep -| Star :: [Hask, Hask] -> Prof

This gives rise to a monad in Prof, (Star.Prep), and a comonad in [Hask,Hask] (Prep.Star)

Prep has a polymorphic kind since 5.6.

Constructors

Instances4Monad, Functor, Applicative, Invariant
classclass (Profunctor p, Functor f) => Cosieve (p :: Type -> Type -> Type) (f :: Type -> Type) | p -> f where
#

A Profunctor p is a Cosieve on f if it is a subprofunctor of Costar f.

That is to say it is a subset of Hom(f-,=) closed under lmap and rmap.

Alternately, you can view it as a cosieve in the comma category f/Hask.

Methods

Instances5Cosieve
newtypenewtype Copastro (p :: Type -> Type -> Type) a b
#

Copastro -| Cotambara

Copastro freely constructs costrength

Constructors

Instances8ProfunctorMonad, ProfunctorAdjunction, ProfunctorFunctor, Costrong, Profunctor, Invariant2, …
classclass Profunctor p => Costrong (p :: Type -> Type -> Type) where
#

Analogous to ArrowLoop, loop = unfirst

Methods

Instances16Costrong, …
datadata Cotambara (q :: Type -> Type -> Type) a b where
#

Cotambara cofreely constructs costrength

Constructors

Instances8ProfunctorComonad, ProfunctorAdjunction, ProfunctorFunctor, Costrong, Profunctor, Invariant2, …
datadata Pastro (p :: Type -> Type -> Type) a b where
#

Pastro -| Tambara

Pastro p ~ exists z. Costar ((,)z) Procompose p Procompose Star ((,)z)

Pastro freely makes any Profunctor Strong.

Constructors

  • Pastro :: ((y, z) -> b) -> p x y -> (a -> (x, z)) -> Pastro p a b
Instances8ProfunctorMonad, ProfunctorAdjunction, ProfunctorFunctor, Strong, Profunctor, Invariant2, …
newtypenewtype Tambara (p :: Type -> Type -> Type) a b
#

Tambara cofreely makes any Profunctor Strong.

Constructors

Instances20ProfunctorComonad, ProfunctorAdjunction, ProfunctorFunctor, Category, Arrow, ArrowApply, …
newtypenewtype CofreeTraversing (p :: Type -> Type -> Type) a b
#

Constructors

Instances7ProfunctorComonad, ProfunctorFunctor, Choice, Strong, Profunctor, Traversing, …
datadata FreeTraversing (p :: Type -> Type -> Type) a b where
#
FreeTraversing -| CofreeTraversing

Constructors

Instances9ProfunctorMonad, ProfunctorFunctor, Choice, Strong, Profunctor, Traversing, …
typetype (:->) (p :: k -> k1 -> Type) (q :: k -> k1 -> Type) = forall (a :: k) (b :: k1). p a b -> q a b
#

(:->) has a polymorphic kind since 5.6.

newtypenewtype Costar (f :: k -> Type) (d :: k) c
#

Lift a Functor into a Profunctor (backwards).

Costar has a polymorphic kind since 5.6.

Constructors

Instances13Cochoice, Closed, Costrong, Profunctor, Corepresentable, Invariant2, …
newtypenewtype Forget r a (b :: k)
#

Forget has a polymorphic kind since 5.6.

Constructors

Instances16Choice, Cochoice, Strong, Profunctor, Traversing, Representable, …
  • Monoid r => Choice (Forget r)Defined in profunctors-5.6.3 · Data.Profunctor.Choice
  • Cochoice (Forget r)Defined in profunctors-5.6.3 · Data.Profunctor.Choice
  • Strong (Forget r)Defined in profunctors-5.6.3 · Data.Profunctor.Strong
  • Profunctor (Forget r)Defined in profunctors-5.6.3 · Data.Profunctor.Types
  • Monoid m => Traversing (Forget m)Defined in profunctors-5.6.3 · Data.Profunctor.Traversing
  • Representable (Forget r)Defined in profunctors-5.6.3 · Data.Profunctor.Rep
  • Invariant2 (Forget r)Defined in invariant-0.6.4 · Data.Functor.Invariant

    from the profunctors package

  • Sieve (Forget r) (Const r)Defined in profunctors-5.6.3 · Data.Profunctor.Sieve
  • Functor (Forget r a)Defined in profunctors-5.6.3 · Data.Profunctor.Types
  • Foldable (Forget r a)Defined in profunctors-5.6.3 · Data.Profunctor.Types
  • Traversable (Forget r a)Defined in profunctors-5.6.3 · Data.Profunctor.Types
  • Contravariant (Forget r a)Defined in profunctors-5.6.3 · Data.Profunctor.Types
  • Invariant (Forget r a)Defined in invariant-0.6.4 · Data.Functor.Invariant

    from the profunctors package

  • Semigroup r => Semigroup (Forget r a b)Defined in profunctors-5.6.3 · Data.Profunctor.Types

    Via Semigroup r => (a -> r)

  • Monoid r => Monoid (Forget r a b)Defined in profunctors-5.6.3 · Data.Profunctor.Types

    Via Monoid r => (a -> r)

  • type Rep (Forget r) = Const rDefined in profunctors-5.6.3 · Data.Profunctor.Rep
newtypenewtype Star (f :: k -> Type) d (c :: k)
#

Lift a Functor into a Profunctor (forwards).

Star has a polymorphic kind since 5.6.

Constructors

Instances20Category, Choice, Cochoice, Closed, Mapping, Strong, …
datadata Coyoneda (p :: Type -> Type -> Type) a b where
#

Constructors

Instances15ProfunctorComonad, ProfunctorMonad, ProfunctorFunctor, Category, Choice, Cochoice, …
datadata Cases a
#

A list of values, equipped with a fast membership test.

newtypenewtype ComposeEither (f :: Type -> Type) e a
#

Composition of a selective functor f with the Either monad.

Constructors

Instances4Functor, Applicative, Alternative, Selective
newtypenewtype ComposeTraversable (f :: Type -> Type) (g :: Type -> Type) a
#

Composition of a selective functor f and an applicative traversable functor g.

Constructors

Instances3Functor, Applicative, Selective
newtypenewtype Over m a
#

Static analysis of selective functors with over-approximation.

Constructors

Instances6Functor, Applicative, Selective, Eq, Ord, Show
  • Functor (Over m)Defined in selective-0.7.0.1 · Control.Selective
  • Monoid m => Applicative (Over m)Defined in selective-0.7.0.1 · Control.Selective
  • Monoid m => Selective (Over m)Defined in selective-0.7.0.1 · Control.Selective
  • Eq m => Eq (Over m a)Defined in selective-0.7.0.1 · Control.Selective
  • Ord m => Ord (Over m a)Defined in selective-0.7.0.1 · Control.Selective
  • Show m => Show (Over m a)Defined in selective-0.7.0.1 · Control.Selective
newtypenewtype SelectA (f :: Type -> Type) a
#

Any applicative functor can be given a Selective instance by defining select = selectA. This data type captures this pattern, so you can use it in combination with the DerivingVia extension as follows:

newtype Over m a = Over m
    deriving (Functor, Applicative, Selective) via SelectA (Const m)

Constructors

Instances3Functor, Applicative, Selective
newtypenewtype SelectM (f :: Type -> Type) a
#

Any monad can be given a Selective instance by defining select = selectM. This data type captures this pattern, so you can use it in combination with the DerivingVia extension as follows:

newtype V1 a = V1 a
    deriving (Functor, Applicative, Selective, Monad) via SelectM Identity

Constructors

Instances4Monad, Functor, Applicative, Selective
newtypenewtype Under m a
#

Static analysis of selective functors with under-approximation.

Constructors

Instances8Functor, Applicative, Foldable, Traversable, Selective, Eq, …
  • Functor (Under m)Defined in selective-0.7.0.1 · Control.Selective
  • Monoid m => Applicative (Under m)Defined in selective-0.7.0.1 · Control.Selective
  • Foldable (Under m)Defined in selective-0.7.0.1 · Control.Selective
  • Traversable (Under m)Defined in selective-0.7.0.1 · Control.Selective
  • Monoid m => Selective (Under m)Defined in selective-0.7.0.1 · Control.Selective
  • Eq m => Eq (Under m a)Defined in selective-0.7.0.1 · Control.Selective
  • Ord m => Ord (Under m a)Defined in selective-0.7.0.1 · Control.Selective
  • Show m => Show (Under m a)Defined in selective-0.7.0.1 · Control.Selective
classclass Bifunctor p => Biapply (p :: Type -> Type -> Type) where
#

Methods

  • (<<.>>) :: p (a -> b) (c -> d) -> p a c -> p b dinfixl 4
  • (.>>) :: p a b -> p c d -> p c dinfixl 4
    a .> b ≡ const id <$> a <.> b
    
  • (<<.) :: p a b -> p c d -> p a binfixl 4
    a <. b ≡ const <$> a <.> b
    
Instances14Biapply, …
newtypenewtype MaybeApply (f :: Type -> Type) a
#

Transform an Apply into an Applicative by adding a unit.

Constructors

Instances7Functor, Applicative, Comonad, Apply, Extend, Copointed, …
newtypenewtype WrappedApplicative (f :: Type -> Type) a
#

Wrap an Applicative to be used as a member of Apply

Instances8Functor, Applicative, Alternative, Alt, Apply, Plus, …
classclass (Bifoldable1 t, Bitraversable t) => Bitraversable1 (t :: Type -> Type -> Type) where
#

Methods

Instances15Bitraversable1, …
classclass (Foldable1 t, Traversable t) => Traversable1 (t :: Type -> Type) where
#

Methods

Instances38Traversable1, …
datadata CalendarDiffDays
#
Instances12Eq, Data, Show, Generic, Semigroup, Monoid, …
newtypenewtype Day
#

The Modified Julian Day is a standard count of days, with zero being the day 1858-11-17.

Instances16Enum, Eq, Data, Ord, Read, Show, …
  • Enum DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • Eq DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • Data DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • Ord DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • Read DayDefined in time-1.12.2 · Data.Time.Format.Parse · orphan
  • Show DayDefined in time-1.12.2 · Data.Time.Calendar.Gregorian · orphan
  • Ix DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • Generic DayDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • NFData DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • Hashable DayDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • DayPeriod DayDefined in time-1.12.2 · Data.Time.Calendar.Days
  • FormatTime DayDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphan
  • ParseTime DayDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphan
  • ISO8601 DayDefined in time-1.12.2 · Data.Time.Format.ISO8601

    yyyy-mm-dd (ISO 8601:2004(E) sec. 4.1.2.2 extended format)

  • Lift DayDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • type Rep Day = D1 ('MetaData "Day" "Data.Time.Calendar.Days" "time-1.12.2-cfd2" 'True) (C1 ('MetaCons "ModifiedJulianDay" 'PrefixI 'True) (S1 ('MetaSel ('Just "toModifiedJulianDay") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer)))Defined in time-compat-1.9.8 · Data.Time.Orphans · orphan
classclass Ord p => DayPeriod p where
#

The class of types which can be represented as a period of days.

Methods

Instances4DayPeriod
typetype MonthOfYear = Int
#

Month of year, in range 1 (January) to 12 (December).

typetype Year = Integer
#

Year of Common Era (when positive).

datadata DayOfWeek
#
Instances11Enum, Eq, Data, Ord, Read, Show, …
  • Enum DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week

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

  • Eq DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Data DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Ord DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Read DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Show DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Ix DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • NFData DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Hashable DayOfWeekDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • FormatTime DayOfWeekDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphan
  • Lift DayOfWeekDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
newtypenewtype DiffTime
#

This is a length of time, as measured by a clock. Conversion functions such as fromInteger and realToFrac will treat it as seconds. For example, (0.010 :: DiffTime) corresponds to 10 milliseconds.

It has a precision of one picosecond (= 10^-12 s). Enumeration functions will treat it as picoseconds.

Instances15Enum, Eq, Fractional, Data, Num, Ord, …
  • Enum DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Eq DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Fractional DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Data DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Num DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Ord DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Read DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Real DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • RealFrac DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Show DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • NFData DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Hashable DiffTimeDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
  • FormatTime DiffTimeDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphan
  • ParseTime DiffTimeDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphan
  • Lift DiffTimeDefined in time-compat-1.9.8 · Data.Time.Orphans · orphan
newtypenewtype NominalDiffTime
#

This is a length of time, as measured by UTC. It has a precision of 10^-12 s.

Conversion functions such as fromInteger and realToFrac will treat it as seconds. For example, (0.010 :: NominalDiffTime) corresponds to 10 milliseconds.

It has a precision of one picosecond (= 10^-12 s). Enumeration functions will treat it as picoseconds.

It ignores leap-seconds, so it's not necessarily a fixed amount of clock time. For instance, 23:00 UTC + 2 hours of NominalDiffTime = 01:00 UTC (+ 1 day), regardless of whether a leap-second intervened.

Instances15Enum, Eq, Fractional, Data, Num, Ord, …
datadata SystemTime
#

SystemTime is time returned by system clock functions. Its semantics depends on the clock function, but the epoch is typically the beginning of 1970. Note that systemNanoseconds of 1E9 to 2E9-1 can be used to represent leap seconds.

Instances5Eq, Data, Ord, Show, NFData
  • Eq SystemTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.SystemTime
  • Data SystemTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.SystemTime
  • Ord SystemTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.SystemTime
  • Show SystemTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.SystemTime
  • NFData SystemTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.SystemTime
datadata UTCTime
#

This is the simplest representation of UTC. It consists of the day number, and a time offset from midnight. Note that if a day has a leap second added to it, it will have 86401 seconds.

Constructors

Instances13Eq, Data, Ord, Read, Show, Generic, …
newtypenewtype UniversalTime
#

The Modified Julian Date is the day with the fraction of the day, measured from UT midnight. It's used to represent UT1, which is time as measured by the earth's rotation, adjusted for various wobbles.

Instances12Eq, Data, Ord, Read, Show, Generic, …
classclass FormatTime t where
#
Instances13FormatTime, …
datadata TimeLocale
#

Constructors

Instances4Eq, Ord, Show, Hashable
classclass ParseTime t where
#

The class of types which can be parsed given a UNIX-style time format string.

Instances12ParseTime, …
datadata CalendarDiffTime
#
Instances11Eq, Data, Show, Generic, Semigroup, Monoid, …
datadata TimeOfDay
#

Time of day as represented in hour, minute and second (with picoseconds), typically used to express local time of day.

TimeOfDay 24 0 0 is considered invalid for the purposes of makeTimeOfDayValid, as well as reading and parsing, but valid for ISO 8601 parsing in Data.Time.Format.ISO8601.

Constructors

  • TimeOfDay
    • todHour :: Int

      range 0 - 23

    • todMin :: Int

      range 0 - 59

    • todSec :: Pico

      Note that 0 <= todSec < 61, accomodating leap seconds. Any local minute may have a leap second, since leap seconds happen in all zones simultaneously

Instances12Eq, Data, Ord, Read, Show, Generic, …
datadata TimeZone
#

A TimeZone is a whole number of minutes offset from UTC, together with a name and a "just for summer" flag.

Constructors

Instances12Eq, Data, Ord, Read, Show, Generic, …
datadata ZonedTime
#

A local time together with a time zone.

There is no Eq instance for ZonedTime. If you want to compare local times, use zonedTimeToLocalTime. If you want to compare absolute times, use zonedTimeToUTC.

Instances9Data, Read, Show, Generic, NFData, FormatTime, …
classclass (forall (m :: Type -> Type). Monad m => Monad (t m)) => MonadTrans (t :: (Type -> Type) -> Type -> Type) where
#

The class of monad transformers. For any monad m, the result t m should also be a monad, and lift should be a monad transformation from m to t m, i.e. it should satisfy the following laws:

Since 0.6.0.0 and for GHC 8.6 and later, the requirement that t m be a Monad is enforced by the implication constraint forall m. Monad m => Monad (t m) enabled by the QuantifiedConstraints extension.

Ambiguity error with GHC 9.0 to 9.2.2

These versions of GHC have a bug (https://gitlab.haskell.org/ghc/ghc/-/issues/20582) which causes constraints like

(MonadTrans t, forall m. Monad m => Monad (t m)) => ...

to be reported as ambiguous. For transformers 0.6 and later, this can be fixed by removing the second constraint, which is implied by the first.

Methods

  • lift :: Monad m => m a -> t m a

    Lift a computation from the argument monad to the constructed monad.

Instances32MonadTrans, …
newtypenewtype ContT (r :: k) (m :: k -> Type) a
#

The continuation monad transformer. Can be used to add continuation handling to any type constructor: the Monad instance and most of the operations do not require m to be a monad.

ContT is not a functor on the category of monads, and many operations cannot be lifted through it.

Constructors

Instances24MonadAccum, MonadReader, MonadState, MonadSelect, MonadBase, MonadFree, …
newtypenewtype ExceptT e (m :: Type -> Type) a
#

A monad transformer that adds exceptions to other monads.

ExceptT constructs a monad parameterized over two things:

  • e - The exception type.

  • m - The inner monad.

The return function yields a computation that produces the given value, while >>= sequences two subcomputations, exiting on the first exception.

Constructors

Instances48MonadRWS, Generic1, MonadAccum, MonadError, MonadReader, MonadState, …
newtypenewtype MaybeT (m :: Type -> Type) a
#

The parameterizable maybe monad, obtained by composing an arbitrary monad with the Maybe monad.

Computations are actions that may produce a value or exit.

The return function yields a computation that produces that value, while >>= sequences two subcomputations, exiting if either computation does.

Constructors

Instances52MonadTrans, MonadRWS, Generic1, MonadAccum, MonadError, MonadReader, …
newtypenewtype ReaderT r (m :: Type -> Type) a
#

The reader monad transformer, which adds a read-only environment to the given monad.

The return function ignores the environment, while m >>= k passes the inherited environment to both subcomputations:

image: images/bind-ReaderT.svg

Constructors

Instances53Generic1, MonadAccum, MonadError, MonadReader, MonadState, MonadWriter, …
newtypenewtype StateT s (m :: Type -> Type) a
#

A state transformer monad parameterized by:

  • s - The state.

  • m - The inner monad.

The return function leaves the state unchanged, while >>= uses the final state of the first computation as the initial state of the second.

Constructors

Instances39MonadAccum, MonadError, MonadReader, MonadState, MonadWriter, MonadSelect, …
newtypenewtype WriterT w (m :: Type -> Type) a
#

A writer monad parameterized by:

  • w - the output to accumulate.

  • m - The inner monad.

The return function produces the output mempty, while m >>= k combines the outputs of the subcomputations using mappend (also known as <>):

image: images/bind-WriterT.svg

Constructors

Instances51MonadAccum, MonadError, MonadReader, MonadState, MonadWriter, MonadSelect, …
datadata HashMap k v
#

A map from keys to values. A map cannot contain duplicate keys; each key can map to at most one value.

Instances41Bifoldable, Eq2, Ord2, Show2, NFData2, Hashable2, …
  • Bifoldable HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Eq2 HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Ord2 HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Show2 HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • NFData2 HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Hashable2 HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (Lift k, Lift v) => Lift (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Functor (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Foldable (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Traversable (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Eq k => Eq1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Ord k => Ord1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (Hashable k, Read k) => Read1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Show k => Show1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • NFData k => NFData1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Hashable k => Hashable1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (Hashable k, Eq k) => Alt (HashMap k)Defined in semigroupoids-6.0.1 · Data.Functor.Alt
  • (Hashable k, Eq k) => Apply (HashMap k)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class

    A 'HashMap k' is not Applicative, but it is an instance of Apply

  • (Hashable k, Eq k) => Bind (HashMap k)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class

    A 'HashMap k' is not a Monad, but it is an instance of Bind

  • (Hashable k, Eq k) => Plus (HashMap k)Defined in semigroupoids-6.0.1 · Data.Functor.Plus
  • Invariant (HashMap k)Defined in invariant-0.6.4 · Data.Functor.Invariant

    from the unordered-containers package

  • FoldableWithKey (HashMap k)Defined in keys-3.12.3 · Data.Key
  • (Eq k, Hashable k) => Indexable (HashMap k)Defined in keys-3.12.3 · Data.Key
  • Keyed (HashMap k)Defined in keys-3.12.3 · Data.Key
  • (Eq k, Hashable k) => Lookup (HashMap k)Defined in keys-3.12.3 · Data.Key
  • TraversableWithKey (HashMap k)Defined in keys-3.12.3 · Data.Key
  • (Eq k, Hashable k) => Zip (HashMap k)Defined in keys-3.12.3 · Data.Key
  • (Eq k, Hashable k) => ZipWithKey (HashMap k)Defined in keys-3.12.3 · Data.Key
  • (Default k, Hashable k) => Pointed (HashMap k)Defined in pointed-5.0.4 · Data.Pointed
  • Hashable k => IsList (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (Eq k, Eq v) => Eq (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal

    Note that, in the presence of hash collisions, equal HashMaps may behave differently, i.e. extensionality may be violated:

    Example2 expressions
    data D = A | B deriving (Eq, Show)instance Hashable D where hashWithSalt salt _d = salt
    Example2 expressions
    x = fromList [(A,1), (B,2)]y = fromList [(B,2), (A,1)]
    Example3 expressions
    x == yTruetoList x[(A,1),(B,2)]toList y[(B,2),(A,1)]

    In general, the lack of extensionality can be observed with any function that depends on the key ordering, such as folds and traversals.

  • (Data k, Data v, Hashable k) => Data (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (Ord k, Ord v) => Ord (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal

    The ordering is total and consistent with the Eq instance. However, nothing else about the ordering is specified, and it may change from version to version of either this package or of hashable.

  • (Hashable k, Read k, Read e) => Read (HashMap k e)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (Show k, Show v) => Show (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • Hashable k => Semigroup (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal

    <> = union

    If a key occurs in both maps, the mapping from the first will be the mapping in the result.

    Examples
    Example1 expression
    fromList [(1,'a'),(2,'b')] <> fromList [(2,'c'),(3,'d')]fromList [(1,'a'),(2,'b'),(3,'d')]
  • Hashable k => Monoid (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal

    mempty = empty

    mappend = union

    If a key occurs in both maps, the mapping from the first will be the mapping in the result.

    Examples
    Example1 expression
    mappend (fromList [(1,'a'),(2,'b')]) (fromList [(2,'c'),(3,'d')])fromList [(1,'a'),(2,'b'),(3,'d')]
  • (NFData k, NFData v) => NFData (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (Hashable k, Hashable v) => Hashable (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • type Item (HashMap k v) = (k, v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • type Key (HashMap k) = kDefined in keys-3.12.3 · Data.Key
datadata Solo a
#

Solo is the canonical lifted 1-tuple, just like Tuple2 is the canonical lifted 2-tuple (pair) and Tuple3 is the canonical lifted 3-tuple (triple).

The most important feature of Solo is that it is possible to force its "outside" (usually by pattern matching) without forcing its "inside", because it is defined as a datatype rather than a newtype. One situation where this can be useful is when writing a function to extract a value from a data structure. Suppose you write an implementation of arrays and offer only this function to index into them:

index :: Array a -> Int -> a

Now imagine that someone wants to extract a value from an array and store it in a lazy-valued finite map/dictionary:

insert "hello" (arr index 12) m

This can actually lead to a space leak. The value is not actually extracted from the array until that value (now buried in a map) is forced. That means the entire array may be kept live by just that value! Often, the solution is to use a strict map, or to force the value before storing it, but for some purposes that's undesirable.

One common solution is to include an indexing function that can produce its result in an arbitrary Applicative context:

indexA :: Applicative f => Array a -> Int -> f a

When using indexA in a pure context, Solo serves as a handy Applicative functor to hold the result. You could write a non-leaky version of the above example thus:

case arr indexA 12 of
  Solo a -> insert "hello" a m

While such simple extraction functions are the most common uses for unary tuples, they can also be useful for fine-grained control of strict-spined data structure traversals, and for unifying the implementations of lazy and strict mapping functions.

Constructors

Instances31Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
patternpattern Solo :: a -> (a)
#

Deprecated. The Solo constructor has been renamed to MkSolo to avoid punning.

datadata RealWorld
#

RealWorld is deeply magical. It is primitive, but it is not unlifted (hence ptrArg). We never manipulate values of type RealWorld; it's only used in the type system, to parameterise State#.

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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Beware that toRational generates garbage for non-finite arguments:

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

    Beware that results for non-finite arguments are garbage:

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

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

  • Show DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan
  • Storable DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • PrintfArg DoubleDefined in base-4.20.2.0 · Text.Printf
  • NFData DoubleDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Pretty DoubleDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Pretty DoubleDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Random DoubleDefined in random-1.2.1.3 · System.Random

    Note - random produces values in the closed range [0,1].

  • UniformRange DoubleDefined in random-1.2.1.3 · System.Random.Internal
  • Binary DoubleDefined in binary-0.8.9.3 · Data.Binary.Class

    Uses non-IEEE754 encoding. Does not round-trip NaN.

  • Hashable DoubleDefined in hashable-1.4.7.0 · Data.Hashable.Class

    Note: prior to hashable-1.3.0.0, hash 0.0 /= hash (-0.0)

    The hash of NaN is not well defined.

  • Prim DoubleDefined in primitive-0.9.1.0 · Data.Primitive.Types
  • Unbox DoubleDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Default DoubleDefined in data-default-0.8.0.1 · Data.Default.Internal
  • Lift DoubleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • IArray UArray DoubleDefined in array-0.5.8.0 · Data.Array.Base
  • Vector Vector DoubleDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector DoubleDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MArray IOUArray Double IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • Generic1 (URec Double)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Foldable UDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Foldable
  • Traversable UDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Traversable
  • MArray (STUArray s) Double (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • Functor (URec Double)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • type Rep (URec Double p) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UDouble" 'PrefixI 'True) (S1 ('MetaSel ('Just "uDouble#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UDouble))Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • type Rep1 (URec Double) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UDouble" 'PrefixI 'True) (S1 ('MetaSel ('Just "uDouble#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UDouble))Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • data URec DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics

    Used for marking occurrences of Double#

  • data MVector s DoubleDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector DoubleDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
datadata Ordering
#
Instances19Bounded, Enum, Eq, Data, Ord, Read, …
classclass a ~ b => (~) (a :: k) (b :: k)
#

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

classclass a ~ b => Coercible (a :: k) (b :: k)
#

Coercible is a two-parameter class that has instances for types a and b if the compiler can infer that they have the same representation. This class does not have regular instances; instead they are created on-the-fly during type-checking. Trying to manually declare an instance of Coercible is an error.

Nevertheless one can pretend that the following three kinds of instances exist. First, as a trivial base-case:

instance Coercible a a

Furthermore, for every type constructor there is an instance that allows to coerce under the type constructor. For example, let D be a prototypical type constructor (data or newtype) with three type arguments, which have roles nominal, representational resp. phantom. Then there is an instance of the form

instance Coercible b b' => Coercible (D a b c) (D a b' c')

Note that the nominal type arguments are equal, the representational type arguments can differ, but need to have a Coercible instance themself, and the phantom type arguments can be changed arbitrarily.

The third kind of instance exists for every newtype NT = MkNT T and comes in two variants, namely

instance Coercible a T => Coercible a NT
instance Coercible T b => Coercible NT b

This instance is only usable if the constructor MkNT is in scope.

If, as a library author of a type constructor like Set a, you want to prevent a user of your module to write coerce :: Set T -> Set NT, you need to set the role of Set's type parameter to nominal, by writing

type role Set nominal

For more details about this feature, please refer to Safe Coercions by Joachim Breitner, Richard A. Eisenberg, Simon Peyton Jones and Stephanie Weirich.

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.

Instances24Enum, Eq, Integral, Data, Num, Ord, …
  • Enum IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Eq IntegerDefined in ghc-bignum-1.3 · GHC.Num.Integer
  • Integral IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Data IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Num
  • Ord IntegerDefined in ghc-bignum-1.3 · GHC.Num.Integer
  • Read IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Real IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Show IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Ix IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Bits IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Bits
  • PrintfArg IntegerDefined in base-4.20.2.0 · Text.Printf
  • NFData IntegerDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Pretty IntegerDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Pretty IntegerDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Random IntegerDefined in random-1.2.1.3 · System.Random

    Note - random generates values in the Int range

  • UniformRange IntegerDefined in random-1.2.1.3 · System.Random.Internal
  • Binary IntegerDefined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable IntegerDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • DayPeriod YearDefined in time-1.12.2 · Data.Time.Calendar.Gregorian · orphan
  • ShowPadded IntegerDefined in time-1.12.2 · Data.Time.Calendar.Private
  • ShowPadded IntegerDefined in time-compat-1.9.8 · Data.Time.Calendar.Private
  • Default IntegerDefined in data-default-0.8.0.1 · Data.Default.Internal
  • Lift IntegerDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
value($) :: (a -> b) -> a -> b
#

($) is the function application operator.

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

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

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

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

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

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

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

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

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

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

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

we can deploy the function application operator:

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

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

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

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

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

If the first argument evaluates to True, then the result is the second argument. Otherwise an AssertionFailed exception is raised, containing a String with the source file and line number of the call to assert.

Assertions can normally be turned on or off with a compiler flag (for GHC, assertions are normally on unless optimisation is turned on with -O or the -fignore-asserts option is given). When assertions are turned off, the first argument to assert is ignored, and the second argument is returned as the result.

valueotherwise :: Bool
#

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

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

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

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

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

Performance considerations

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

Examples
Example1 expression
[1, 2, 3] ++ [4, 5, 6][1,2,3,4,5,6]
Example1 expression
[] ++ [1, 2, 3][1,2,3]
Example1 expression
[3, 2, 1] ++ [][3,2,1]
valuemap :: (a -> b) -> [a] -> [b]
#

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

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

this means that map id == id

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

The join function is the conventional monad join operator. It is used to remove one level of monadic structure, projecting its bound argument into the outer level.

'join bss' can be understood as the do expression

do bs <- bss
   bs
Examples
Example1 expression
join [[1, 2, 3], [4, 5, 6], [7, 8, 9]][1,2,3,4,5,6,7,8,9]
Example1 expression
join (Just (Just 3))Just 3

A common use of join is to run an IO computation returned from an GHC.Conc.STM transaction, since GHC.Conc.STM transactions can't perform IO directly. Recall that

GHC.Internal.Conc.atomically :: STM a -> IO a

is used to run GHC.Conc.STM transactions atomically. So, by specializing the types of GHC.Internal.Conc.atomically and join to

GHC.Internal.Conc.atomically :: STM (IO b) -> IO (IO b)
join       :: IO (IO b)  -> IO b

we can compose them as

join . GHC.Internal.Conc.atomically :: STM (IO b) -> IO b

to run an GHC.Conc.STM transaction and the IO action it returns.

valueguard :: Alternative f => Bool -> f ()
#

Conditional failure of Alternative computations. Defined by

guard True  = pure ()
guard False = empty
Examples

Common uses of guard include conditionally signalling an error in an error monad and conditionally rejecting the current choice in an Alternative-based parser.

As an example of signalling an error in the error monad Maybe, consider a safe division function safeDiv x y that returns Nothing when the denominator y is zero and Just (x `div` y) otherwise. For example:

Example1 expression
safeDiv 4 0Nothing
Example1 expression
safeDiv 4 2Just 2

A definition of safeDiv using guards, but not guard:

safeDiv :: Int -> Int -> Maybe Int
safeDiv x y | y /= 0    = Just (x `div` y)
            | otherwise = Nothing

A definition of safeDiv using guard and Monad do-notation:

safeDiv :: Int -> Int -> Maybe Int
safeDiv x y = do
  guard (y /= 0)
  return (x `div` y)
valuetoDyn :: Typeable a => a -> Dynamic
#

Converts an arbitrary value into an object of type Dynamic.

The type of the object must be an instance of Typeable, which ensures that only monomorphically-typed objects may be converted to Dynamic. To convert a polymorphic object into Dynamic, give it a monomorphic type signature. For example:

   toDyn (id :: Int -> Int)
valuetrace :: String -> a -> a
#

The trace function outputs the trace message given as its first argument, before returning the second argument as its result.

For example, this returns the value of f x and outputs the message to stderr. Depending on your terminal (settings), they may or may not be mixed.

Example2 expressions
let x = 123; f = showtrace ("calling f with x = " ++ show x) (f x)calling f with x = 123"123"

The trace function should only be used for debugging, or for monitoring execution. The function is not referentially transparent: its type indicates that it is a pure function but it has the side effect of outputting the trace message.

valuezip :: [a] -> [b] -> [(a, b)]
#

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

zip is right-lazy:

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

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

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

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

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

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

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

A value of type FunPtr a is a pointer to a function callable from foreign code. The type a will normally be a foreign type, a function type with zero or more arguments where

A value of type FunPtr a may be a pointer to a foreign function, either returned by another foreign function or imported with a a static address import like

foreign import ccall "stdlib.h &free"
  p_free :: FunPtr (Ptr a -> IO ())

or a pointer to a Haskell function created using a wrapper stub declared to produce a FunPtr of the correct type. For example:

type Compare = Int -> Int -> Bool
foreign import ccall "wrapper"
  mkCompare :: Compare -> IO (FunPtr Compare)

Calls to wrapper stubs like mkCompare allocate storage, which should be released with freeHaskellFunPtr when no longer required.

To convert FunPtr values to corresponding Haskell functions, one can define a dynamic stub for the specific foreign type, e.g.

type IntFunction = CInt -> IO ()
foreign import ccall "dynamic"
  mkFun :: FunPtr IntFunction -> IntFunction
Instances12NFData1, IArray, Eq, Ord, Show, Storable, …
  • NFData1 FunPtrDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • IArray UArray (FunPtr a)Defined in array-0.5.8.0 · Data.Array.Base
  • MArray IOUArray (FunPtr a) IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • Eq (FunPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Ord (FunPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Show (FunPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Storable (FunPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • NFData (FunPtr a)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • Hashable (FunPtr a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Prim (FunPtr a)Defined in primitive-0.9.1.0 · Data.Primitive.Types
  • Default (FunPtr a)Defined in data-default-0.8.0.1 · Data.Default.Internal
  • MArray (STUArray s) (FunPtr a) (ST s)Defined in array-0.5.8.0 · Data.Array.Base
valuerealToFrac :: (Real a, Fractional b) => a -> b
#

General coercion to Fractional types.

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

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

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

General coercion from Integral types.

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

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.

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

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

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

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

Highly, terribly dangerous coercion from one representation type to another. Misuse of this function can invite the garbage collector to trounce upon your data and then laugh in your face. You don't want this function. Really.

datadata UnsafeEquality (a :: k) (b :: k) where
#

This type is treated magically within GHC. Any pattern match of the form case unsafeEqualityProof of UnsafeRefl -> body gets transformed just into body. This is ill-typed, but the transformation takes place after type-checking is complete. It is used to implement unsafeCoerce. You probably don't want to use UnsafeRefl in an expression, but you might conceivably want to pattern-match on it. Use unsafeEqualityProof to create one of these.

Constructors

datadata Word64
#

64-bit unsigned integer type

Instances36Bounded, Enum, Eq, Integral, Data, Num, …
  • Bounded Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Enum Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Eq Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Data Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ord Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Read Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Real Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Show Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ix Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Bits Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • FiniteBits Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Storable Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • PrintfArg Word64Defined in base-4.20.2.0 · Text.Printf
  • NFData Word64Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • Mantissa Word64Defined in bytestring-0.12.2.0 · Data.ByteString.Builder.RealFloat.Internal
  • Random Word64Defined in random-1.2.1.3 · System.Random
  • Finite Word64Defined in random-1.2.1.3 · System.Random.GFinite
  • Uniform Word64Defined in random-1.2.1.3 · System.Random.Internal
  • UniformRange Word64Defined in random-1.2.1.3 · System.Random.Internal
  • Binary Word64Defined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable Word64Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Prim Word64Defined in primitive-0.9.1.0 · Data.Primitive.Types
  • Unbox Word64Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • ByteSource Word64Defined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
  • Default Word64Defined in data-default-0.8.0.1 · Data.Default.Internal
  • Lift Word64Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • IArray UArray Word64Defined in array-0.5.8.0 · Data.Array.Base
  • Vector Vector Word64Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector Word64Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MArray IOUArray Word64 IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • MArray (STUArray s) Word64 (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • data MVector s Word64Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector Word64Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • type ByteSink Word64 g = Takes8Bytes gDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
datadata Word32
#

32-bit unsigned integer type

Instances36Bounded, Enum, Eq, Integral, Data, Num, …
  • Bounded Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Enum Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Eq Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Data Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ord Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Read Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Real Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Show Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ix Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Bits Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • FiniteBits Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Storable Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • PrintfArg Word32Defined in base-4.20.2.0 · Text.Printf
  • NFData Word32Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • Mantissa Word32Defined in bytestring-0.12.2.0 · Data.ByteString.Builder.RealFloat.Internal
  • Random Word32Defined in random-1.2.1.3 · System.Random
  • Finite Word32Defined in random-1.2.1.3 · System.Random.GFinite
  • Uniform Word32Defined in random-1.2.1.3 · System.Random.Internal
  • UniformRange Word32Defined in random-1.2.1.3 · System.Random.Internal
  • Binary Word32Defined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable Word32Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Prim Word32Defined in primitive-0.9.1.0 · Data.Primitive.Types
  • Unbox Word32Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • ByteSource Word32Defined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
  • Default Word32Defined in data-default-0.8.0.1 · Data.Default.Internal
  • Lift Word32Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • IArray UArray Word32Defined in array-0.5.8.0 · Data.Array.Base
  • Vector Vector Word32Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector Word32Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MArray IOUArray Word32 IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • MArray (STUArray s) Word32 (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • data MVector s Word32Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector Word32Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • type ByteSink Word32 g = Takes4Bytes gDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
datadata Word16
#

16-bit unsigned integer type

Instances35Bounded, Enum, Eq, Integral, Data, Num, …
  • Bounded Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Enum Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Eq Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Data Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ord Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Read Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Real Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Show Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ix Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Bits Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • FiniteBits Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Storable Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • PrintfArg Word16Defined in base-4.20.2.0 · Text.Printf
  • NFData Word16Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • Random Word16Defined in random-1.2.1.3 · System.Random
  • Finite Word16Defined in random-1.2.1.3 · System.Random.GFinite
  • Uniform Word16Defined in random-1.2.1.3 · System.Random.Internal
  • UniformRange Word16Defined in random-1.2.1.3 · System.Random.Internal
  • Binary Word16Defined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable Word16Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Prim Word16Defined in primitive-0.9.1.0 · Data.Primitive.Types
  • Unbox Word16Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • ByteSource Word16Defined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
  • Default Word16Defined in data-default-0.8.0.1 · Data.Default.Internal
  • Lift Word16Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • IArray UArray Word16Defined in array-0.5.8.0 · Data.Array.Base
  • Vector Vector Word16Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector Word16Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MArray IOUArray Word16 IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • MArray (STUArray s) Word16 (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • data MVector s Word16Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector Word16Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • type ByteSink Word16 g = Takes2Bytes gDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
datadata Word8
#

8-bit unsigned integer type

Instances35Bounded, Enum, Eq, Integral, Data, Num, …
  • Bounded Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Enum Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Eq Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Data Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ord Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Read Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Real Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Show Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Ix Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Bits Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • FiniteBits Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Storable Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • PrintfArg Word8Defined in base-4.20.2.0 · Text.Printf
  • NFData Word8Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • Random Word8Defined in random-1.2.1.3 · System.Random
  • Finite Word8Defined in random-1.2.1.3 · System.Random.GFinite
  • Uniform Word8Defined in random-1.2.1.3 · System.Random.Internal
  • UniformRange Word8Defined in random-1.2.1.3 · System.Random.Internal
  • Binary Word8Defined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable Word8Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Prim Word8Defined in primitive-0.9.1.0 · Data.Primitive.Types
  • Unbox Word8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • ByteSource Word8Defined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
  • Default Word8Defined in data-default-0.8.0.1 · Data.Default.Internal
  • Lift Word8Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • IArray UArray Word8Defined in array-0.5.8.0 · Data.Array.Base
  • Vector Vector Word8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector Word8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MArray IOUArray Word8 IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • MArray (STUArray s) Word8 (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • data MVector s Word8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector Word8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • type ByteSink Word8 g = Takes1Byte gDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
datadata TyCon
#
Instances5Eq, Ord, Show, NFData, Binary
  • Eq TyConDefined in ghc-prim-0.12.0 · GHC.Classes
  • Ord TyConDefined in ghc-prim-0.12.0 · GHC.Classes
  • Show TyConDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • NFData TyConDefined in deepseq-1.5.0.0 · Control.DeepSeq

    NOTE: Prior to deepseq-1.4.4.0 this instance was only defined for base-4.8.0.0 and later.

  • Binary TyConDefined in binary-0.8.9.3 · Data.Binary.Class
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

Instances17IsString, …
  • IsString BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder · orphan
  • IsString ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type

    Beware: fromString truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�

  • IsString ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal

    Beware: fromString truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�

  • IsString ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal

    Beware: fromString truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�

  • IsString DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJ
  • IsString TextDefined in text-2.1.3 · Data.Text · orphan

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedStrings"\55555" :: Text"\65533"
  • IsString BuilderDefined in text-2.1.3 · Data.Text.Internal.Builder

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedStrings"\55555" :: Builder"\65533"
  • IsString TextDefined in text-2.1.3 · Data.Text.Lazy · orphan

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedStrings"\55555" :: Data.Text.Lazy.Text"\65533"
  • IsString (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • IsString a => IsString (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.String
  • (IsString a, Hashable a) => IsString (Hashed a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • a ~ Char => IsString (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • a ~ Char => IsString (DNonEmpty a)Defined in dlist-1.0 · Data.DList.DNonEmpty.Internal
  • a ~ Char => IsString (DList a)Defined in dlist-1.0 · Data.DList.Internal
  • 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
  • IsString a => IsString (Tagged s a)Defined in tagged-0.8.9 · Data.Tagged
datadata Int64
#

64-bit signed integer type

Instances33Bounded, Enum, Eq, Integral, Data, Num, …
  • Bounded Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Enum Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Eq Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Data Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ord Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Show Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ix Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Bits Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • FiniteBits Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Storable Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • PrintfArg Int64Defined in base-4.20.2.0 · Text.Printf
  • NFData Int64Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • Random Int64Defined in random-1.2.1.3 · System.Random
  • Finite Int64Defined in random-1.2.1.3 · System.Random.GFinite
  • Uniform Int64Defined in random-1.2.1.3 · System.Random.Internal
  • UniformRange Int64Defined in random-1.2.1.3 · System.Random.Internal
  • Binary Int64Defined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable Int64Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Prim Int64Defined in primitive-0.9.1.0 · Data.Primitive.Types
  • Unbox Int64Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Default Int64Defined in data-default-0.8.0.1 · Data.Default.Internal
  • Lift Int64Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • IArray UArray Int64Defined in array-0.5.8.0 · Data.Array.Base
  • Vector Vector Int64Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector Int64Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MArray IOUArray Int64 IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • MArray (STUArray s) Int64 (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • data MVector s Int64Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector Int64Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
datadata Int32
#

32-bit signed integer type

Instances33Bounded, Enum, Eq, Integral, Data, Num, …
  • Bounded Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Enum Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Eq Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Data Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ord Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Show Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ix Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Bits Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • FiniteBits Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Storable Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • PrintfArg Int32Defined in base-4.20.2.0 · Text.Printf
  • NFData Int32Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • Random Int32Defined in random-1.2.1.3 · System.Random
  • Finite Int32Defined in random-1.2.1.3 · System.Random.GFinite
  • Uniform Int32Defined in random-1.2.1.3 · System.Random.Internal
  • UniformRange Int32Defined in random-1.2.1.3 · System.Random.Internal
  • Binary Int32Defined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable Int32Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Prim Int32Defined in primitive-0.9.1.0 · Data.Primitive.Types
  • Unbox Int32Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Default Int32Defined in data-default-0.8.0.1 · Data.Default.Internal
  • Lift Int32Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • IArray UArray Int32Defined in array-0.5.8.0 · Data.Array.Base
  • Vector Vector Int32Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector Int32Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MArray IOUArray Int32 IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • MArray (STUArray s) Int32 (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • data MVector s Int32Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector Int32Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
datadata Int16
#

16-bit signed integer type

Instances33Bounded, Enum, Eq, Integral, Data, Num, …
  • Bounded Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Enum Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Eq Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Data Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ord Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Show Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ix Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Bits Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • FiniteBits Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Storable Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • PrintfArg Int16Defined in base-4.20.2.0 · Text.Printf
  • NFData Int16Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • Random Int16Defined in random-1.2.1.3 · System.Random
  • Finite Int16Defined in random-1.2.1.3 · System.Random.GFinite
  • Uniform Int16Defined in random-1.2.1.3 · System.Random.Internal
  • UniformRange Int16Defined in random-1.2.1.3 · System.Random.Internal
  • Binary Int16Defined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable Int16Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Prim Int16Defined in primitive-0.9.1.0 · Data.Primitive.Types
  • Unbox Int16Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Default Int16Defined in data-default-0.8.0.1 · Data.Default.Internal
  • Lift Int16Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • IArray UArray Int16Defined in array-0.5.8.0 · Data.Array.Base
  • Vector Vector Int16Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector Int16Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MArray IOUArray Int16 IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • MArray (STUArray s) Int16 (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • data MVector s Int16Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector Int16Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
datadata Int8
#

8-bit signed integer type

Instances33Bounded, Enum, Eq, Integral, Data, Num, …
  • Bounded Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Enum Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Eq Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Data Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ord Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Show Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Ix Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Bits Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • FiniteBits Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Storable Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • PrintfArg Int8Defined in base-4.20.2.0 · Text.Printf
  • NFData Int8Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • Random Int8Defined in random-1.2.1.3 · System.Random
  • Finite Int8Defined in random-1.2.1.3 · System.Random.GFinite
  • Uniform Int8Defined in random-1.2.1.3 · System.Random.Internal
  • UniformRange Int8Defined in random-1.2.1.3 · System.Random.Internal
  • Binary Int8Defined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable Int8Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Prim Int8Defined in primitive-0.9.1.0 · Data.Primitive.Types
  • Unbox Int8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Default Int8Defined in data-default-0.8.0.1 · Data.Default.Internal
  • Lift Int8Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • IArray UArray Int8Defined in array-0.5.8.0 · Data.Array.Base
  • Vector Vector Int8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector Int8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MArray IOUArray Int8 IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • MArray (STUArray s) Int8 (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • data MVector s Int8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector Int8Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
valueinline :: a -> a
#

The call inline f arranges that f is inlined, regardless of its size. More precisely, the call inline f rewrites to the right-hand side of f's definition. This allows the programmer to control inlining from a particular call site rather than the definition site of the function (c.f. INLINE pragmas).

This inlining occurs regardless of the argument to the call or the size of f's definition; it is unconditional. The main caveat is that f's definition must be visible to the compiler; it is therefore recommended to mark the function with an INLINABLE pragma at its definition so that GHC guarantees to record its unfolding regardless of size.

If no inlining takes place, the inline function expands to the identity function in Phase zero, so its use imposes no overhead.

valuelazy :: a -> a
#

The lazy function restrains strictness analysis a little. The call lazy e means the same as e, but lazy has a magical property so far as strictness analysis is concerned: it is lazy in its first argument, even though its semantics is strict. After strictness analysis has run, calls to lazy are inlined to be the identity function.

This behaviour is occasionally useful when controlling evaluation order. Notably, lazy is used in the library definition of par:

par :: a -> b -> b
par x y = case (par# x) of _ -> lazy y

If lazy were not lazy, par would look strict in y which would defeat the whole purpose of par.

classclass Monad m => MonadFix (m :: Type -> Type) where
#

Monads having fixed points with a 'knot-tying' semantics. Instances of MonadFix should satisfy the following laws:

Purity

mfix (return . h) = return (fix h)

Left shrinking (or Tightening)

mfix (\x -> a >>= \y -> f x y) = a >>= \y -> mfix (\x -> f x y)

Sliding

mfix (liftM h . f) = liftM h (mfix (f . h))

, for strict

h

.

Nesting

mfix (\x -> mfix (\y -> f x y)) = mfix (\x -> f x x)

This class is used in the translation of the recursive do notation supported by GHC and Hugs.

Methods

  • mfix :: (a -> m a) -> m a

    The fixed point of a monadic computation. mfix f executes the action f only once, with the eventual output fed back as the input. Hence f should not be strict, for then mfix f would diverge.

Instances58MonadFix, …
classclass Monad m => MonadFail (m :: Type -> Type) where
#

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

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

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

fail s >>= f  =  fail s

If your Monad is also MonadPlus, a popular definition is

fail _ = mzero

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

Methods

Instances39MonadFail, …
valuecoerce :: Coercible a b => a -> b
#

The function coerce allows you to safely convert between values of types that have the same representation with no run-time overhead. In the simplest case you can use it instead of a newtype constructor, to go from the newtype's concrete type to the abstract type. But it also works in more complicated settings, e.g. converting a list of newtypes to a list of concrete types.

When used in conversions involving a newtype wrapper, make sure the newtype constructor is in scope.

This function is representation-polymorphic, but the RuntimeRep type argument is marked as Inferred, meaning that it is not available for visible type application. This means the typechecker will accept coerce @Int @Age 42.

Examples
Example5 expressions
newtype TTL = TTL Int deriving (Eq, Ord, Show)newtype Age = Age Int deriving (Eq, Ord, Show)coerce (Age 42) :: TTLTTL 42coerce (+ (1 :: Int)) (Age 42) :: TTLTTL 43coerce (map (+ (1 :: Int))) [Age 42, Age 24] :: [TTL][TTL 43,TTL 25]
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 HasField (x :: k) r a | x r -> a where
#

Constraint representing the fact that the field x belongs to the record type r and has field type a. This will be solved automatically, but manual instances may be provided as well.

Methods

  • getField :: r -> a

    Selector function to extract the field from the record.