base-4.13.0.0: Basic libraries

GHC.Base

Description

Basic data types and classes.

Synopsis

# Documentation

augment :: forall a. (forall b. (a -> b -> b) -> b -> b) -> [a] -> [a] #

A list producer that can be fused with foldr. This function is merely

   augment g xs = g (:) xs

but GHC's simplifier will transform an expression of the form foldr k z (augment g xs), which may arise after inlining, to g k (foldr k z xs), which avoids producing an intermediate list.

(++) :: [a] -> [a] -> [a] infixr 5 #

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

build :: forall a. (forall b. (a -> b -> b) -> b -> b) -> [a] #

A list producer that can be fused with foldr. This function is merely

   build g = g (:) []

but GHC's simplifier will transform an expression of the form foldr k z (build g), which may arise after inlining, to g k z, which avoids producing an intermediate list.

foldr :: (a -> b -> b) -> b -> [a] -> b #

foldr, 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)...)

This String equality predicate is used when desugaring pattern-matches against strings.

bindIO :: IO a -> (a -> IO b) -> IO b #

returnIO :: a -> IO a #

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

 f x | x < 0     = ...
| otherwise = ...

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

thenIO :: IO a -> IO b -> IO b #

breakpoint :: a -> a #

breakpointCond :: Bool -> a -> a #

map :: (a -> b) -> [a] -> [b] #

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, ...]
>>> map (+1) [1, 2, 3]


($) :: forall r a (b :: TYPE r). (a -> b) -> a -> b infixr 0 # Application operator. This operator is redundant, since ordinary application (f x) means the same as (f$ x). However, $ has low, right-associative binding precedence, so it sometimes allows parentheses to be omitted; for example: f$ g $h x = f (g (h x)) It is also useful in higher-order situations, such as map ($ 0) xs, or zipWith ($) fs xs. Note that ($) is levity-polymorphic in its result type, so that foo $True where foo :: Bool -> Int# is well-typed. join :: 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. #### Examples Expand A common use of join is to run an IO computation returned from an STM transaction, since STM transactions can't perform IO directly. Recall that atomically :: STM a -> IO a  is used to run STM transactions atomically. So, by specializing the types of atomically and join to atomically :: STM (IO b) -> IO (IO b) join :: IO (IO b) -> IO b  we can compose them as join . atomically :: STM (IO b) -> IO b  to run an STM transaction and the IO action it returns. class Applicative m => Monad m 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: • pure = return • (<*>) = ap The above laws imply: • fmap f xs = xs >>= return . f • (>>) = (*>) and that pure and (<*>) satisfy the applicative functor laws. The instances of Monad for lists, Maybe and IO defined in the Prelude satisfy these laws. Minimal complete definition (>>=) Methods (>>=) :: forall a b. m a -> (a -> m b) -> m b infixl 1 # Sequentially compose two actions, passing any value produced by the first as an argument to the second. (>>) :: forall a b. m a -> m b -> m b infixl 1 # Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages. return :: a -> m a # Inject a value into the monadic type. #### Instances Instances details  Monad [] # Since: base-2.1 Instance detailsDefined in GHC.Base Methods(>>=) :: [a] -> (a -> [b]) -> [b] #(>>) :: [a] -> [b] -> [b] #return :: a -> [a] # # Since: base-2.1 Instance detailsDefined in GHC.Base Methods(>>=) :: Maybe a -> (a -> Maybe b) -> Maybe b #(>>) :: Maybe a -> Maybe b -> Maybe b #return :: a -> Maybe a # # Since: base-2.1 Instance detailsDefined in GHC.Base Methods(>>=) :: IO a -> (a -> IO b) -> IO b #(>>) :: IO a -> IO b -> IO b #return :: a -> IO a # # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods(>>=) :: Par1 a -> (a -> Par1 b) -> Par1 b #(>>) :: Par1 a -> Par1 b -> Par1 b #return :: a -> Par1 a # # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(>>=) :: NonEmpty a -> (a -> NonEmpty b) -> NonEmpty b #(>>) :: NonEmpty a -> NonEmpty b -> NonEmpty b #return :: a -> NonEmpty a # # Since: base-4.4.0.0 Instance detailsDefined in GHC.GHCi Methods(>>=) :: NoIO a -> (a -> NoIO b) -> NoIO b #(>>) :: NoIO a -> NoIO b -> NoIO b #return :: a -> NoIO a # # Since: base-2.1 Instance detailsDefined in Text.ParserCombinators.ReadP Methods(>>=) :: ReadP a -> (a -> ReadP b) -> ReadP b #(>>) :: ReadP a -> ReadP b -> ReadP b #return :: a -> ReadP a # # Since: base-2.1 Instance detailsDefined in Text.ParserCombinators.ReadPrec Methods(>>=) :: ReadPrec a -> (a -> ReadPrec b) -> ReadPrec b #(>>) :: ReadPrec a -> ReadPrec b -> ReadPrec b #return :: a -> ReadPrec a # # Since: base-4.11.0.0 Instance detailsDefined in Data.Ord Methods(>>=) :: Down a -> (a -> Down b) -> Down b #(>>) :: Down a -> Down b -> Down b #return :: a -> Down a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methods(>>=) :: Product a -> (a -> Product b) -> Product b #(>>) :: Product a -> Product b -> Product b #return :: a -> Product a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methods(>>=) :: Sum a -> (a -> Sum b) -> Sum b #(>>) :: Sum a -> Sum b -> Sum b #return :: a -> Sum a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methods(>>=) :: Dual a -> (a -> Dual b) -> Dual b #(>>) :: Dual a -> Dual b -> Dual b #return :: a -> Dual a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Monoid Methods(>>=) :: Last a -> (a -> Last b) -> Last b #(>>) :: Last a -> Last b -> Last b #return :: a -> Last a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Monoid Methods(>>=) :: First a -> (a -> First b) -> First b #(>>) :: First a -> First b -> First b #return :: a -> First a # # Since: base-4.3.0.0 Instance detailsDefined in GHC.Conc.Sync Methods(>>=) :: STM a -> (a -> STM b) -> STM b #(>>) :: STM a -> STM b -> STM b #return :: a -> STM a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Functor.Identity Methods(>>=) :: Identity a -> (a -> Identity b) -> Identity b #(>>) :: Identity a -> Identity b -> Identity b #return :: a -> Identity a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(>>=) :: Option a -> (a -> Option b) -> Option b #(>>) :: Option a -> Option b -> Option b #return :: a -> Option a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(>>=) :: Last a -> (a -> Last b) -> Last b #(>>) :: Last a -> Last b -> Last b #return :: a -> Last a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(>>=) :: First a -> (a -> First b) -> First b #(>>) :: First a -> First b -> First b #return :: a -> First a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(>>=) :: Max a -> (a -> Max b) -> Max b #(>>) :: Max a -> Max b -> Max b #return :: a -> Max a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(>>=) :: Min a -> (a -> Min b) -> Min b #(>>) :: Min a -> Min b -> Min b #return :: a -> Min a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Complex Methods(>>=) :: Complex a -> (a -> Complex b) -> Complex b #(>>) :: Complex a -> Complex b -> Complex b #return :: a -> Complex a # Monad (Either e) # Since: base-4.4.0.0 Instance detailsDefined in Data.Either Methods(>>=) :: Either e a -> (a -> Either e b) -> Either e b #(>>) :: Either e a -> Either e b -> Either e b #return :: a -> Either e a # Monad (U1 :: Type -> Type) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods(>>=) :: U1 a -> (a -> U1 b) -> U1 b #(>>) :: U1 a -> U1 b -> U1 b #return :: a -> U1 a # Monoid a => Monad ((,) a) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(>>=) :: (a, a0) -> (a0 -> (a, b)) -> (a, b) #(>>) :: (a, a0) -> (a, b) -> (a, b) #return :: a0 -> (a, a0) # Monad (ST s) # Since: base-2.1 Instance detailsDefined in GHC.ST Methods(>>=) :: ST s a -> (a -> ST s b) -> ST s b #(>>) :: ST s a -> ST s b -> ST s b #return :: a -> ST s a # Monad (Proxy :: Type -> Type) # Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methods(>>=) :: Proxy a -> (a -> Proxy b) -> Proxy b #(>>) :: Proxy a -> Proxy b -> Proxy b #return :: a -> Proxy a # ArrowApply a => Monad (ArrowMonad a) # Since: base-2.1 Instance detailsDefined in Control.Arrow Methods(>>=) :: ArrowMonad a a0 -> (a0 -> ArrowMonad a b) -> ArrowMonad a b #(>>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b #return :: a0 -> ArrowMonad a a0 # Monad m => Monad (WrappedMonad m) # Since: base-4.7.0.0 Instance detailsDefined in Control.Applicative Methods(>>=) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b #(>>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b #return :: a -> WrappedMonad m a # Monad (ST s) # Since: base-2.1 Instance detailsDefined in Control.Monad.ST.Lazy.Imp Methods(>>=) :: ST s a -> (a -> ST s b) -> ST s b #(>>) :: ST s a -> ST s b -> ST s b #return :: a -> ST s a # Monad f => Monad (Rec1 f) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods(>>=) :: Rec1 f a -> (a -> Rec1 f b) -> Rec1 f b #(>>) :: Rec1 f a -> Rec1 f b -> Rec1 f b #return :: a -> Rec1 f a # Monad f => Monad (Alt f) # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methods(>>=) :: Alt f a -> (a -> Alt f b) -> Alt f b #(>>) :: Alt f a -> Alt f b -> Alt f b #return :: a -> Alt f a # Monad f => Monad (Ap f) # Since: base-4.12.0.0 Instance detailsDefined in Data.Monoid Methods(>>=) :: Ap f a -> (a -> Ap f b) -> Ap f b #(>>) :: Ap f a -> Ap f b -> Ap f b #return :: a -> Ap f a # Monad ((->) r :: Type -> Type) # Since: base-2.1 Instance detailsDefined in GHC.Base Methods(>>=) :: (r -> a) -> (a -> r -> b) -> r -> b #(>>) :: (r -> a) -> (r -> b) -> r -> b #return :: a -> r -> a # (Monad f, Monad g) => Monad (f :*: g) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods(>>=) :: (f :*: g) a -> (a -> (f :*: g) b) -> (f :*: g) b #(>>) :: (f :*: g) a -> (f :*: g) b -> (f :*: g) b #return :: a -> (f :*: g) a # (Monad f, Monad g) => Monad (Product f g) # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Product Methods(>>=) :: Product f g a -> (a -> Product f g b) -> Product f g b #(>>) :: Product f g a -> Product f g b -> Product f g b #return :: a -> Product f g a # Monad f => Monad (M1 i c f) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods(>>=) :: M1 i c f a -> (a -> M1 i c f b) -> M1 i c f b #(>>) :: M1 i c f a -> M1 i c f b -> M1 i c f b #return :: a -> M1 i c f a # class Functor f 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. Minimal complete definition fmap Methods fmap :: (a -> b) -> f a -> f b # (<$) :: a -> f b -> f a infixl 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.

#### Instances

Instances details
 Functor [] # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsfmap :: (a -> b) -> [a] -> [b] #(<$) :: a -> [b] -> [a] # # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsfmap :: (a -> b) -> Maybe a -> Maybe b #(<$) :: a -> Maybe b -> Maybe a # # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsfmap :: (a -> b) -> IO a -> IO b #(<$) :: a -> IO b -> IO a # # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> Par1 a -> Par1 b #(<$) :: a -> Par1 b -> Par1 a # # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methodsfmap :: (a -> b) -> NonEmpty a -> NonEmpty b #(<$) :: a -> NonEmpty b -> NonEmpty a # # Since: base-4.8.0.0 Instance detailsDefined in GHC.GHCi Methodsfmap :: (a -> b) -> NoIO a -> NoIO b #(<$) :: a -> NoIO b -> NoIO a # # Since: base-2.1 Instance detailsDefined in Text.ParserCombinators.ReadP Methodsfmap :: (a -> b) -> ReadP a -> ReadP b #(<$) :: a -> ReadP b -> ReadP a # # Since: base-2.1 Instance detailsDefined in Text.ParserCombinators.ReadPrec Methodsfmap :: (a -> b) -> ReadPrec a -> ReadPrec b #(<$) :: a -> ReadPrec b -> ReadPrec a # # Since: base-4.11.0.0 Instance detailsDefined in Data.Ord Methodsfmap :: (a -> b) -> Down a -> Down b #(<$) :: a -> Down b -> Down a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methodsfmap :: (a -> b) -> Product a -> Product b #(<$) :: a -> Product b -> Product a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methodsfmap :: (a -> b) -> Sum a -> Sum b #(<$) :: a -> Sum b -> Sum a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methodsfmap :: (a -> b) -> Dual a -> Dual b #(<$) :: a -> Dual b -> Dual a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Monoid Methodsfmap :: (a -> b) -> Last a -> Last b #(<$) :: a -> Last b -> Last a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Monoid Methodsfmap :: (a -> b) -> First a -> First b #(<$) :: a -> First b -> First a # # Since: base-4.3.0.0 Instance detailsDefined in GHC.Conc.Sync Methodsfmap :: (a -> b) -> STM a -> STM b #(<$) :: a -> STM b -> STM a # # Since: base-4.6.0.0 Instance detailsDefined in Control.Exception Methodsfmap :: (a -> b) -> Handler a -> Handler b #(<$) :: a -> Handler b -> Handler a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Functor.Identity Methodsfmap :: (a -> b) -> Identity a -> Identity b #(<$) :: a -> Identity b -> Identity a # # Since: base-2.1 Instance detailsDefined in Control.Applicative Methodsfmap :: (a -> b) -> ZipList a -> ZipList b #(<$) :: a -> ZipList b -> ZipList a # # Since: base-4.6.0.0 Instance detailsDefined in System.Console.GetOpt Methodsfmap :: (a -> b) -> ArgDescr a -> ArgDescr b #(<$) :: a -> ArgDescr b -> ArgDescr a # # Since: base-4.6.0.0 Instance detailsDefined in System.Console.GetOpt Methodsfmap :: (a -> b) -> OptDescr a -> OptDescr b #(<$) :: a -> OptDescr b -> OptDescr a # # Since: base-4.6.0.0 Instance detailsDefined in System.Console.GetOpt Methodsfmap :: (a -> b) -> ArgOrder a -> ArgOrder b #(<$) :: a -> ArgOrder b -> ArgOrder a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsfmap :: (a -> b) -> Option a -> Option b #(<$) :: a -> Option b -> Option a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsfmap :: (a -> b) -> Last a -> Last b #(<$) :: a -> Last b -> Last a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsfmap :: (a -> b) -> First a -> First b #(<$) :: a -> First b -> First a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsfmap :: (a -> b) -> Max a -> Max b #(<$) :: a -> Max b -> Max a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsfmap :: (a -> b) -> Min a -> Min b #(<$) :: a -> Min b -> Min a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Complex Methodsfmap :: (a -> b) -> Complex a -> Complex b #(<$) :: a -> Complex b -> Complex a # # Since: base-3.0 Instance detailsDefined in Data.Either Methodsfmap :: (a0 -> b) -> Either a a0 -> Either a b #(<$) :: a0 -> Either a b -> Either a a0 # Functor (V1 :: Type -> Type) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> V1 a -> V1 b #(<$) :: a -> V1 b -> V1 a # Functor (U1 :: Type -> Type) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> U1 a -> U1 b #(<$) :: a -> U1 b -> U1 a # Functor ((,) a) # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsfmap :: (a0 -> b) -> (a, a0) -> (a, b) #(<$) :: a0 -> (a, b) -> (a, a0) # Functor (ST s) # Since: base-2.1 Instance detailsDefined in GHC.ST Methodsfmap :: (a -> b) -> ST s a -> ST s b #(<$) :: a -> ST s b -> ST s a # Functor (Array i) # Since: base-2.1 Instance detailsDefined in GHC.Arr Methodsfmap :: (a -> b) -> Array i a -> Array i b #(<$) :: a -> Array i b -> Array i a # Functor (Proxy :: Type -> Type) # Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methodsfmap :: (a -> b) -> Proxy a -> Proxy b #(<$) :: a -> Proxy b -> Proxy a # Arrow a => Functor (ArrowMonad a) # Since: base-4.6.0.0 Instance detailsDefined in Control.Arrow Methodsfmap :: (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b #(<$) :: a0 -> ArrowMonad a b -> ArrowMonad a a0 # Monad m => Functor (WrappedMonad m) # Since: base-2.1 Instance detailsDefined in Control.Applicative Methodsfmap :: (a -> b) -> WrappedMonad m a -> WrappedMonad m b #(<$) :: a -> WrappedMonad m b -> WrappedMonad m a # Functor (ST s) # Since: base-2.1 Instance detailsDefined in Control.Monad.ST.Lazy.Imp Methodsfmap :: (a -> b) -> ST s a -> ST s b #(<$) :: a -> ST s b -> ST s a # Functor (Arg a) # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsfmap :: (a0 -> b) -> Arg a a0 -> Arg a b #(<$) :: a0 -> Arg a b -> Arg a a0 # Functor f => Functor (Rec1 f) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> Rec1 f a -> Rec1 f b #(<$) :: a -> Rec1 f b -> Rec1 f a # Functor (URec Char :: Type -> Type) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> URec Char a -> URec Char b #(<$) :: a -> URec Char b -> URec Char a # # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> URec Double a -> URec Double b #(<$) :: a -> URec Double b -> URec Double a # Functor (URec Float :: Type -> Type) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> URec Float a -> URec Float b #(<$) :: a -> URec Float b -> URec Float a # Functor (URec Int :: Type -> Type) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> URec Int a -> URec Int b #(<$) :: a -> URec Int b -> URec Int a # Functor (URec Word :: Type -> Type) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> URec Word a -> URec Word b #(<$) :: a -> URec Word b -> URec Word a # Functor (URec (Ptr ()) :: Type -> Type) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> URec (Ptr ()) a -> URec (Ptr ()) b #(<$) :: a -> URec (Ptr ()) b -> URec (Ptr ()) a # Functor f => Functor (Alt f) # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methodsfmap :: (a -> b) -> Alt f a -> Alt f b #(<$) :: a -> Alt f b -> Alt f a # Functor f => Functor (Ap f) # Since: base-4.12.0.0 Instance detailsDefined in Data.Monoid Methodsfmap :: (a -> b) -> Ap f a -> Ap f b #(<$) :: a -> Ap f b -> Ap f a # Functor (Const m :: Type -> Type) # Since: base-2.1 Instance detailsDefined in Data.Functor.Const Methodsfmap :: (a -> b) -> Const m a -> Const m b #(<$) :: a -> Const m b -> Const m a # Arrow a => Functor (WrappedArrow a b) # Since: base-2.1 Instance detailsDefined in Control.Applicative Methodsfmap :: (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 #(<$) :: a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 # Functor ((->) r :: Type -> Type) # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsfmap :: (a -> b) -> (r -> a) -> r -> b #(<$) :: a -> (r -> b) -> r -> a # Functor (K1 i c :: Type -> Type) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> K1 i c a -> K1 i c b #(<$) :: a -> K1 i c b -> K1 i c a # (Functor f, Functor g) => Functor (f :+: g) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> (f :+: g) a -> (f :+: g) b #(<$) :: a -> (f :+: g) b -> (f :+: g) a # (Functor f, Functor g) => Functor (f :*: g) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> (f :*: g) a -> (f :*: g) b #(<$) :: a -> (f :*: g) b -> (f :*: g) a # (Functor f, Functor g) => Functor (Sum f g) # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Sum Methodsfmap :: (a -> b) -> Sum f g a -> Sum f g b #(<$) :: a -> Sum f g b -> Sum f g a # (Functor f, Functor g) => Functor (Product f g) # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Product Methodsfmap :: (a -> b) -> Product f g a -> Product f g b #(<$) :: a -> Product f g b -> Product f g a # Functor f => Functor (M1 i c f) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> M1 i c f a -> M1 i c f b #(<$) :: a -> M1 i c f b -> M1 i c f a # (Functor f, Functor g) => Functor (f :.: g) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsfmap :: (a -> b) -> (f :.: g) a -> (f :.: g) b #(<$) :: a -> (f :.: g) b -> (f :.: g) a # (Functor f, Functor g) => Functor (Compose f g) # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Compose Methodsfmap :: (a -> b) -> Compose f g a -> Compose f g b #(<$) :: a -> Compose f g b -> Compose f g a #

class Functor f => Applicative f 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:

• u *> v = (id <$ u) <*> v • u <* v = liftA2 const u v As a consequence of these laws, the Functor instance for f will satisfy • fmap f x = pure f <*> x 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 • pure = return • (<*>) = ap • (*>) = (>>) (which implies that pure and <*> satisfy the applicative functor laws). Minimal complete definition pure, ((<*>) | liftA2) Methods pure :: a -> f a # Lift a value. (<*>) :: f (a -> b) -> f a -> f b infixl 4 # Sequential application. A few functors support an implementation of <*> that is more efficient than the default one. 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 <*>. (*>) :: f a -> f b -> f b infixl 4 # Sequence actions, discarding the value of the first argument. (<*) :: f a -> f b -> f a infixl 4 # Sequence actions, discarding the value of the second argument. #### Instances Instances details  # Since: base-2.1 Instance detailsDefined in GHC.Base Methodspure :: a -> [a] #(<*>) :: [a -> b] -> [a] -> [b] #liftA2 :: (a -> b -> c) -> [a] -> [b] -> [c] #(*>) :: [a] -> [b] -> [b] #(<*) :: [a] -> [b] -> [a] # # Since: base-2.1 Instance detailsDefined in GHC.Base Methodspure :: a -> Maybe a #(<*>) :: Maybe (a -> b) -> Maybe a -> Maybe b #liftA2 :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c #(*>) :: Maybe a -> Maybe b -> Maybe b #(<*) :: Maybe a -> Maybe b -> Maybe a # # Since: base-2.1 Instance detailsDefined in GHC.Base Methodspure :: a -> IO a #(<*>) :: IO (a -> b) -> IO a -> IO b #liftA2 :: (a -> b -> c) -> IO a -> IO b -> IO c #(*>) :: IO a -> IO b -> IO b #(<*) :: IO a -> IO b -> IO a # # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodspure :: a -> Par1 a #(<*>) :: Par1 (a -> b) -> Par1 a -> Par1 b #liftA2 :: (a -> b -> c) -> Par1 a -> Par1 b -> Par1 c #(*>) :: Par1 a -> Par1 b -> Par1 b #(<*) :: Par1 a -> Par1 b -> Par1 a # # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methodspure :: a -> NonEmpty a #(<*>) :: NonEmpty (a -> b) -> NonEmpty a -> NonEmpty b #liftA2 :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c #(*>) :: NonEmpty a -> NonEmpty b -> NonEmpty b #(<*) :: NonEmpty a -> NonEmpty b -> NonEmpty a # # Since: base-4.8.0.0 Instance detailsDefined in GHC.GHCi Methodspure :: a -> NoIO a #(<*>) :: NoIO (a -> b) -> NoIO a -> NoIO b #liftA2 :: (a -> b -> c) -> NoIO a -> NoIO b -> NoIO c #(*>) :: NoIO a -> NoIO b -> NoIO b #(<*) :: NoIO a -> NoIO b -> NoIO a # # Since: base-4.6.0.0 Instance detailsDefined in Text.ParserCombinators.ReadP Methodspure :: a -> ReadP a #(<*>) :: ReadP (a -> b) -> ReadP a -> ReadP b #liftA2 :: (a -> b -> c) -> ReadP a -> ReadP b -> ReadP c #(*>) :: ReadP a -> ReadP b -> ReadP b #(<*) :: ReadP a -> ReadP b -> ReadP a # # Since: base-4.6.0.0 Instance detailsDefined in Text.ParserCombinators.ReadPrec Methodspure :: a -> ReadPrec a #(<*>) :: ReadPrec (a -> b) -> ReadPrec a -> ReadPrec b #liftA2 :: (a -> b -> c) -> ReadPrec a -> ReadPrec b -> ReadPrec c #(*>) :: ReadPrec a -> ReadPrec b -> ReadPrec b #(<*) :: ReadPrec a -> ReadPrec b -> ReadPrec a # # Since: base-4.11.0.0 Instance detailsDefined in Data.Ord Methodspure :: a -> Down a #(<*>) :: Down (a -> b) -> Down a -> Down b #liftA2 :: (a -> b -> c) -> Down a -> Down b -> Down c #(*>) :: Down a -> Down b -> Down b #(<*) :: Down a -> Down b -> Down a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methodspure :: a -> Product a #(<*>) :: Product (a -> b) -> Product a -> Product b #liftA2 :: (a -> b -> c) -> Product a -> Product b -> Product c #(*>) :: Product a -> Product b -> Product b #(<*) :: Product a -> Product b -> Product a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methodspure :: a -> Sum a #(<*>) :: Sum (a -> b) -> Sum a -> Sum b #liftA2 :: (a -> b -> c) -> Sum a -> Sum b -> Sum c #(*>) :: Sum a -> Sum b -> Sum b #(<*) :: Sum a -> Sum b -> Sum a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methodspure :: a -> Dual a #(<*>) :: Dual (a -> b) -> Dual a -> Dual b #liftA2 :: (a -> b -> c) -> Dual a -> Dual b -> Dual c #(*>) :: Dual a -> Dual b -> Dual b #(<*) :: Dual a -> Dual b -> Dual a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Monoid Methodspure :: a -> Last a #(<*>) :: Last (a -> b) -> Last a -> Last b #liftA2 :: (a -> b -> c) -> Last a -> Last b -> Last c #(*>) :: Last a -> Last b -> Last b #(<*) :: Last a -> Last b -> Last a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Monoid Methodspure :: a -> First a #(<*>) :: First (a -> b) -> First a -> First b #liftA2 :: (a -> b -> c) -> First a -> First b -> First c #(*>) :: First a -> First b -> First b #(<*) :: First a -> First b -> First a # # Since: base-4.8.0.0 Instance detailsDefined in GHC.Conc.Sync Methodspure :: a -> STM a #(<*>) :: STM (a -> b) -> STM a -> STM b #liftA2 :: (a -> b -> c) -> STM a -> STM b -> STM c #(*>) :: STM a -> STM b -> STM b #(<*) :: STM a -> STM b -> STM a # # Since: base-4.8.0.0 Instance detailsDefined in Data.Functor.Identity Methodspure :: a -> Identity a #(<*>) :: Identity (a -> b) -> Identity a -> Identity b #liftA2 :: (a -> b -> c) -> Identity a -> Identity b -> Identity c #(*>) :: Identity a -> Identity b -> Identity b #(<*) :: Identity a -> Identity b -> Identity a # # f <$> ZipList xs1 <*> ... <*> ZipList xsN = ZipList (zipWithN f xs1 ... xsN)where zipWithN refers to the zipWith function of the appropriate arity (zipWith, zipWith3, zipWith4, ...). For example:(\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..] = ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..]) = ZipList {getZipList = ["a5","b6b6","c7c7c7"]}Since: base-2.1 Instance detailsDefined in Control.Applicative Methodspure :: a -> ZipList a #(<*>) :: ZipList (a -> b) -> ZipList a -> ZipList b #liftA2 :: (a -> b -> c) -> ZipList a -> ZipList b -> ZipList c #(*>) :: ZipList a -> ZipList b -> ZipList b #(<*) :: ZipList a -> ZipList b -> ZipList a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodspure :: a -> Option a #(<*>) :: Option (a -> b) -> Option a -> Option b #liftA2 :: (a -> b -> c) -> Option a -> Option b -> Option c #(*>) :: Option a -> Option b -> Option b #(<*) :: Option a -> Option b -> Option a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodspure :: a -> Last a #(<*>) :: Last (a -> b) -> Last a -> Last b #liftA2 :: (a -> b -> c) -> Last a -> Last b -> Last c #(*>) :: Last a -> Last b -> Last b #(<*) :: Last a -> Last b -> Last a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodspure :: a -> First a #(<*>) :: First (a -> b) -> First a -> First b #liftA2 :: (a -> b -> c) -> First a -> First b -> First c #(*>) :: First a -> First b -> First b #(<*) :: First a -> First b -> First a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodspure :: a -> Max a #(<*>) :: Max (a -> b) -> Max a -> Max b #liftA2 :: (a -> b -> c) -> Max a -> Max b -> Max c #(*>) :: Max a -> Max b -> Max b #(<*) :: Max a -> Max b -> Max a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodspure :: a -> Min a #(<*>) :: Min (a -> b) -> Min a -> Min b #liftA2 :: (a -> b -> c) -> Min a -> Min b -> Min c #(*>) :: Min a -> Min b -> Min b #(<*) :: Min a -> Min b -> Min a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Complex Methodspure :: a -> Complex a #(<*>) :: Complex (a -> b) -> Complex a -> Complex b #liftA2 :: (a -> b -> c) -> Complex a -> Complex b -> Complex c #(*>) :: Complex a -> Complex b -> Complex b #(<*) :: Complex a -> Complex b -> Complex a # # Since: base-3.0 Instance detailsDefined in Data.Either Methodspure :: a -> Either e a #(<*>) :: Either e (a -> b) -> Either e a -> Either e b #liftA2 :: (a -> b -> c) -> Either e a -> Either e b -> Either e c #(*>) :: Either e a -> Either e b -> Either e b #(<*) :: Either e a -> Either e b -> Either e a # Applicative (U1 :: Type -> Type) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodspure :: a -> U1 a #(<*>) :: U1 (a -> b) -> U1 a -> U1 b #liftA2 :: (a -> b -> c) -> U1 a -> U1 b -> U1 c #(*>) :: U1 a -> U1 b -> U1 b #(<*) :: U1 a -> U1 b -> U1 a # Monoid a => Applicative ((,) a) # For tuples, the Monoid constraint on a determines how the first values merge. For example, Strings concatenate:("hello ", (+15)) <*> ("world!", 2002) ("hello world!",2017)Since: base-2.1 Instance detailsDefined in GHC.Base Methodspure :: a0 -> (a, a0) #(<*>) :: (a, a0 -> b) -> (a, a0) -> (a, b) #liftA2 :: (a0 -> b -> c) -> (a, a0) -> (a, b) -> (a, c) #(*>) :: (a, a0) -> (a, b) -> (a, b) #(<*) :: (a, a0) -> (a, b) -> (a, a0) # # Since: base-4.4.0.0 Instance detailsDefined in GHC.ST Methodspure :: a -> ST s a #(<*>) :: ST s (a -> b) -> ST s a -> ST s b #liftA2 :: (a -> b -> c) -> ST s a -> ST s b -> ST s c #(*>) :: ST s a -> ST s b -> ST s b #(<*) :: ST s a -> ST s b -> ST s a # Applicative (Proxy :: Type -> Type) # Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methodspure :: a -> Proxy a #(<*>) :: Proxy (a -> b) -> Proxy a -> Proxy b #liftA2 :: (a -> b -> c) -> Proxy a -> Proxy b -> Proxy c #(*>) :: Proxy a -> Proxy b -> Proxy b #(<*) :: Proxy a -> Proxy b -> Proxy a # Arrow a => Applicative (ArrowMonad a) # Since: base-4.6.0.0 Instance detailsDefined in Control.Arrow Methodspure :: a0 -> ArrowMonad a a0 #(<*>) :: ArrowMonad a (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b #liftA2 :: (a0 -> b -> c) -> ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a c #(*>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b #(<*) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a a0 # Monad m => Applicative (WrappedMonad m) # Since: base-2.1 Instance detailsDefined in Control.Applicative Methodspure :: a -> WrappedMonad m a #(<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b #liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c #(*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b #(<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a # # Since: base-2.1 Instance detailsDefined in Control.Monad.ST.Lazy.Imp Methodspure :: a -> ST s a #(<*>) :: ST s (a -> b) -> ST s a -> ST s b #liftA2 :: (a -> b -> c) -> ST s a -> ST s b -> ST s c #(*>) :: ST s a -> ST s b -> ST s b #(<*) :: ST s a -> ST s b -> ST s a # Applicative f => Applicative (Rec1 f) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodspure :: a -> Rec1 f a #(<*>) :: Rec1 f (a -> b) -> Rec1 f a -> Rec1 f b #liftA2 :: (a -> b -> c) -> Rec1 f a -> Rec1 f b -> Rec1 f c #(*>) :: Rec1 f a -> Rec1 f b -> Rec1 f b #(<*) :: Rec1 f a -> Rec1 f b -> Rec1 f a # Applicative f => Applicative (Alt f) # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methodspure :: a -> Alt f a #(<*>) :: Alt f (a -> b) -> Alt f a -> Alt f b #liftA2 :: (a -> b -> c) -> Alt f a -> Alt f b -> Alt f c #(*>) :: Alt f a -> Alt f b -> Alt f b #(<*) :: Alt f a -> Alt f b -> Alt f a # Applicative f => Applicative (Ap f) # Since: base-4.12.0.0 Instance detailsDefined in Data.Monoid Methodspure :: a -> Ap f a #(<*>) :: Ap f (a -> b) -> Ap f a -> Ap f b #liftA2 :: (a -> b -> c) -> Ap f a -> Ap f b -> Ap f c #(*>) :: Ap f a -> Ap f b -> Ap f b #(<*) :: Ap f a -> Ap f b -> Ap f a # Monoid m => Applicative (Const m :: Type -> Type) # Since: base-2.0.1 Instance detailsDefined in Data.Functor.Const Methodspure :: a -> Const m a #(<*>) :: Const m (a -> b) -> Const m a -> Const m b #liftA2 :: (a -> b -> c) -> Const m a -> Const m b -> Const m c #(*>) :: Const m a -> Const m b -> Const m b #(<*) :: Const m a -> Const m b -> Const m a # Arrow a => Applicative (WrappedArrow a b) # Since: base-2.1 Instance detailsDefined in Control.Applicative Methodspure :: a0 -> WrappedArrow a b a0 #(<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 #liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c #(*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 #(<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 # Applicative ((->) a :: Type -> Type) # Since: base-2.1 Instance detailsDefined in GHC.Base Methodspure :: a0 -> a -> a0 #(<*>) :: (a -> (a0 -> b)) -> (a -> a0) -> a -> b #liftA2 :: (a0 -> b -> c) -> (a -> a0) -> (a -> b) -> a -> c #(*>) :: (a -> a0) -> (a -> b) -> a -> b #(<*) :: (a -> a0) -> (a -> b) -> a -> a0 # Monoid c => Applicative (K1 i c :: Type -> Type) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methodspure :: a -> K1 i c a #(<*>) :: K1 i c (a -> b) -> K1 i c a -> K1 i c b #liftA2 :: (a -> b -> c0) -> K1 i c a -> K1 i c b -> K1 i c c0 #(*>) :: K1 i c a -> K1 i c b -> K1 i c b #(<*) :: K1 i c a -> K1 i c b -> K1 i c a # (Applicative f, Applicative g) => Applicative (f :*: g) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodspure :: a -> (f :*: g) a #(<*>) :: (f :*: g) (a -> b) -> (f :*: g) a -> (f :*: g) b #liftA2 :: (a -> b -> c) -> (f :*: g) a -> (f :*: g) b -> (f :*: g) c #(*>) :: (f :*: g) a -> (f :*: g) b -> (f :*: g) b #(<*) :: (f :*: g) a -> (f :*: g) b -> (f :*: g) a # (Applicative f, Applicative g) => Applicative (Product f g) # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Product Methodspure :: a -> Product f g a #(<*>) :: Product f g (a -> b) -> Product f g a -> Product f g b #liftA2 :: (a -> b -> c) -> Product f g a -> Product f g b -> Product f g c #(*>) :: Product f g a -> Product f g b -> Product f g b #(<*) :: Product f g a -> Product f g b -> Product f g a # Applicative f => Applicative (M1 i c f) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodspure :: a -> M1 i c f a #(<*>) :: M1 i c f (a -> b) -> M1 i c f a -> M1 i c f b #liftA2 :: (a -> b -> c0) -> M1 i c f a -> M1 i c f b -> M1 i c f c0 #(*>) :: M1 i c f a -> M1 i c f b -> M1 i c f b #(<*) :: M1 i c f a -> M1 i c f b -> M1 i c f a # (Applicative f, Applicative g) => Applicative (f :.: g) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodspure :: a -> (f :.: g) a #(<*>) :: (f :.: g) (a -> b) -> (f :.: g) a -> (f :.: g) b #liftA2 :: (a -> b -> c) -> (f :.: g) a -> (f :.: g) b -> (f :.: g) c #(*>) :: (f :.: g) a -> (f :.: g) b -> (f :.: g) b #(<*) :: (f :.: g) a -> (f :.: g) b -> (f :.: g) a # (Applicative f, Applicative g) => Applicative (Compose f g) # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Compose Methodspure :: a -> Compose f g a #(<*>) :: Compose f g (a -> b) -> Compose f g a -> Compose f g b #liftA2 :: (a -> b -> c) -> Compose f g a -> Compose f g b -> Compose f g c #(*>) :: Compose f g a -> Compose f g b -> Compose f g b #(<*) :: Compose f g a -> Compose f g b -> Compose f g a # class 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 Since: base-4.9.0.0 Minimal complete definition (<>) Methods (<>) :: a -> a -> a infixr 6 # An associative operation. sconcat :: NonEmpty a -> a # Reduce a non-empty list with <> The default definition should be sufficient, but this can be overridden for efficiency. stimes :: Integral b => b -> a -> a # Repeat a value n times. Given that this works on a Semigroup it is allowed to fail if you request 0 or fewer repetitions, and the default definition will do so. By making this a member of the class, idempotent semigroups and monoids can upgrade this to execute in O(1) by picking stimes = stimesIdempotent or stimes = stimesIdempotentMonoid respectively. #### Instances Instances details  # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methodsstimes :: Integral b => b -> Ordering -> Ordering # # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: () -> () -> () #sconcat :: NonEmpty () -> () #stimes :: Integral b => b -> () -> () # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup.Internal Methods(<>) :: Any -> Any -> Any #stimes :: Integral b => b -> Any -> Any # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup.Internal Methods(<>) :: All -> All -> All #stimes :: Integral b => b -> All -> All # # Since: base-4.10.0.0 Instance detailsDefined in GHC.Event.Internal Methodsstimes :: Integral b => b -> Lifetime -> Lifetime # # Since: base-4.10.0.0 Instance detailsDefined in GHC.Event.Internal Methods(<>) :: Event -> Event -> Event #stimes :: Integral b => b -> Event -> Event # # Since: base-4.9.0.0 Instance detailsDefined in Data.Void Methods(<>) :: Void -> Void -> Void #stimes :: Integral b => b -> Void -> Void # Semigroup [a] # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: [a] -> [a] -> [a] #sconcat :: NonEmpty [a] -> [a] #stimes :: Integral b => b -> [a] -> [a] # Semigroup a => Semigroup (Maybe a) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: Maybe a -> Maybe a -> Maybe a #sconcat :: NonEmpty (Maybe a) -> Maybe a #stimes :: Integral b => b -> Maybe a -> Maybe a # Semigroup a => Semigroup (IO a) # Since: base-4.10.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: IO a -> IO a -> IO a #sconcat :: NonEmpty (IO a) -> IO a #stimes :: Integral b => b -> IO a -> IO a # Semigroup p => Semigroup (Par1 p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methods(<>) :: Par1 p -> Par1 p -> Par1 p #sconcat :: NonEmpty (Par1 p) -> Par1 p #stimes :: Integral b => b -> Par1 p -> Par1 p # # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: NonEmpty a -> NonEmpty a -> NonEmpty a #sconcat :: NonEmpty (NonEmpty a) -> NonEmpty a #stimes :: Integral b => b -> NonEmpty a -> NonEmpty a # Semigroup a => Semigroup (Down a) # Since: base-4.11.0.0 Instance detailsDefined in Data.Ord Methods(<>) :: Down a -> Down a -> Down a #sconcat :: NonEmpty (Down a) -> Down a #stimes :: Integral b => b -> Down a -> Down a # Num a => Semigroup (Product a) # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup.Internal Methods(<>) :: Product a -> Product a -> Product a #sconcat :: NonEmpty (Product a) -> Product a #stimes :: Integral b => b -> Product a -> Product a # Num a => Semigroup (Sum a) # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup.Internal Methods(<>) :: Sum a -> Sum a -> Sum a #sconcat :: NonEmpty (Sum a) -> Sum a #stimes :: Integral b => b -> Sum a -> Sum a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup.Internal Methods(<>) :: Endo a -> Endo a -> Endo a #sconcat :: NonEmpty (Endo a) -> Endo a #stimes :: Integral b => b -> Endo a -> Endo a # Semigroup a => Semigroup (Dual a) # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup.Internal Methods(<>) :: Dual a -> Dual a -> Dual a #sconcat :: NonEmpty (Dual a) -> Dual a #stimes :: Integral b => b -> Dual a -> Dual a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Monoid Methods(<>) :: Last a -> Last a -> Last a #sconcat :: NonEmpty (Last a) -> Last a #stimes :: Integral b => b -> Last a -> Last a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Monoid Methods(<>) :: First a -> First a -> First a #sconcat :: NonEmpty (First a) -> First a #stimes :: Integral b => b -> First a -> First a # Semigroup a => Semigroup (Identity a) # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Identity Methods(<>) :: Identity a -> Identity a -> Identity a #sconcat :: NonEmpty (Identity a) -> Identity a #stimes :: Integral b => b -> Identity a -> Identity a # Semigroup a => Semigroup (Option a) # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(<>) :: Option a -> Option a -> Option a #sconcat :: NonEmpty (Option a) -> Option a #stimes :: Integral b => b -> Option a -> Option a # Monoid m => Semigroup (WrappedMonoid m) # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(<>) :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m #stimes :: Integral b => b -> WrappedMonoid m -> WrappedMonoid m # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(<>) :: Last a -> Last a -> Last a #sconcat :: NonEmpty (Last a) -> Last a #stimes :: Integral b => b -> Last a -> Last a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(<>) :: First a -> First a -> First a #sconcat :: NonEmpty (First a) -> First a #stimes :: Integral b => b -> First a -> First a # Ord a => Semigroup (Max a) # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(<>) :: Max a -> Max a -> Max a #sconcat :: NonEmpty (Max a) -> Max a #stimes :: Integral b => b -> Max a -> Max a # Ord a => Semigroup (Min a) # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(<>) :: Min a -> Min a -> Min a #sconcat :: NonEmpty (Min a) -> Min a #stimes :: Integral b => b -> Min a -> Min a # # Instance detailsDefined in Data.Functor.Contravariant Methods(<>) :: Equivalence a -> Equivalence a -> Equivalence a #stimes :: Integral b => b -> Equivalence a -> Equivalence a # # Instance detailsDefined in Data.Functor.Contravariant Methods(<>) :: Comparison a -> Comparison a -> Comparison a #sconcat :: NonEmpty (Comparison a) -> Comparison a #stimes :: Integral b => b -> Comparison a -> Comparison a # # Instance detailsDefined in Data.Functor.Contravariant Methods(<>) :: Predicate a -> Predicate a -> Predicate a #sconcat :: NonEmpty (Predicate a) -> Predicate a #stimes :: Integral b => b -> Predicate a -> Predicate a # Semigroup b => Semigroup (a -> b) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: (a -> b) -> (a -> b) -> a -> b #sconcat :: NonEmpty (a -> b) -> a -> b #stimes :: Integral b0 => b0 -> (a -> b) -> a -> b # Semigroup (Either a b) # Since: base-4.9.0.0 Instance detailsDefined in Data.Either Methods(<>) :: Either a b -> Either a b -> Either a b #sconcat :: NonEmpty (Either a b) -> Either a b #stimes :: Integral b0 => b0 -> Either a b -> Either a b # Semigroup (V1 p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methods(<>) :: V1 p -> V1 p -> V1 p #sconcat :: NonEmpty (V1 p) -> V1 p #stimes :: Integral b => b -> V1 p -> V1 p # Semigroup (U1 p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methods(<>) :: U1 p -> U1 p -> U1 p #sconcat :: NonEmpty (U1 p) -> U1 p #stimes :: Integral b => b -> U1 p -> U1 p # (Semigroup a, Semigroup b) => Semigroup (a, b) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: (a, b) -> (a, b) -> (a, b) #sconcat :: NonEmpty (a, b) -> (a, b) #stimes :: Integral b0 => b0 -> (a, b) -> (a, b) # Semigroup a => Semigroup (ST s a) # Since: base-4.11.0.0 Instance detailsDefined in GHC.ST Methods(<>) :: ST s a -> ST s a -> ST s a #sconcat :: NonEmpty (ST s a) -> ST s a #stimes :: Integral b => b -> ST s a -> ST s a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Proxy Methods(<>) :: Proxy s -> Proxy s -> Proxy s #sconcat :: NonEmpty (Proxy s) -> Proxy s #stimes :: Integral b => b -> Proxy s -> Proxy s # Semigroup a => Semigroup (Op a b) # Instance detailsDefined in Data.Functor.Contravariant Methods(<>) :: Op a b -> Op a b -> Op a b #sconcat :: NonEmpty (Op a b) -> Op a b #stimes :: Integral b0 => b0 -> Op a b -> Op a b # Semigroup (f p) => Semigroup (Rec1 f p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methods(<>) :: Rec1 f p -> Rec1 f p -> Rec1 f p #sconcat :: NonEmpty (Rec1 f p) -> Rec1 f p #stimes :: Integral b => b -> Rec1 f p -> Rec1 f p # (Semigroup a, Semigroup b, Semigroup c) => Semigroup (a, b, c) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: (a, b, c) -> (a, b, c) -> (a, b, c) #sconcat :: NonEmpty (a, b, c) -> (a, b, c) #stimes :: Integral b0 => b0 -> (a, b, c) -> (a, b, c) # Alternative f => Semigroup (Alt f a) # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup.Internal Methods(<>) :: Alt f a -> Alt f a -> Alt f a #sconcat :: NonEmpty (Alt f a) -> Alt f a #stimes :: Integral b => b -> Alt f a -> Alt f a # (Applicative f, Semigroup a) => Semigroup (Ap f a) # Since: base-4.12.0.0 Instance detailsDefined in Data.Monoid Methods(<>) :: Ap f a -> Ap f a -> Ap f a #sconcat :: NonEmpty (Ap f a) -> Ap f a #stimes :: Integral b => b -> Ap f a -> Ap f a # Semigroup a => Semigroup (Const a b) # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Const Methods(<>) :: Const a b -> Const a b -> Const a b #sconcat :: NonEmpty (Const a b) -> Const a b #stimes :: Integral b0 => b0 -> Const a b -> Const a b # Semigroup c => Semigroup (K1 i c p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methods(<>) :: K1 i c p -> K1 i c p -> K1 i c p #sconcat :: NonEmpty (K1 i c p) -> K1 i c p #stimes :: Integral b => b -> K1 i c p -> K1 i c p # (Semigroup (f p), Semigroup (g p)) => Semigroup ((f :*: g) p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methods(<>) :: (f :*: g) p -> (f :*: g) p -> (f :*: g) p #sconcat :: NonEmpty ((f :*: g) p) -> (f :*: g) p #stimes :: Integral b => b -> (f :*: g) p -> (f :*: g) p # (Semigroup a, Semigroup b, Semigroup c, Semigroup d) => Semigroup (a, b, c, d) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) #sconcat :: NonEmpty (a, b, c, d) -> (a, b, c, d) #stimes :: Integral b0 => b0 -> (a, b, c, d) -> (a, b, c, d) # Semigroup (f p) => Semigroup (M1 i c f p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methods(<>) :: M1 i c f p -> M1 i c f p -> M1 i c f p #sconcat :: NonEmpty (M1 i c f p) -> M1 i c f p #stimes :: Integral b => b -> M1 i c f p -> M1 i c f p # Semigroup (f (g p)) => Semigroup ((f :.: g) p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methods(<>) :: (f :.: g) p -> (f :.: g) p -> (f :.: g) p #sconcat :: NonEmpty ((f :.: g) p) -> (f :.: g) p #stimes :: Integral b => b -> (f :.: g) p -> (f :.: g) p # (Semigroup a, Semigroup b, Semigroup c, Semigroup d, Semigroup e) => Semigroup (a, b, c, d, e) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) #sconcat :: NonEmpty (a, b, c, d, e) -> (a, b, c, d, e) #stimes :: Integral b0 => b0 -> (a, b, c, d, e) -> (a, b, c, d, e) # class 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 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. Sum and Product. NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0. Minimal complete definition mempty Methods mempty :: a # Identity of mappend mappend :: a -> a -> a # An associative operation NOTE: This method is redundant and has the default implementation mappend = (<>) since base-4.11.0.0. 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. #### Instances Instances details  # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsmconcat :: [Ordering] -> Ordering # Monoid () # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsmempty :: () #mappend :: () -> () -> () #mconcat :: [()] -> () # # Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methodsmappend :: Any -> Any -> Any #mconcat :: [Any] -> Any # # Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methodsmappend :: All -> All -> All #mconcat :: [All] -> All # # mappend takes the longer of two lifetimes.Since: base-4.8.0.0 Instance detailsDefined in GHC.Event.Internal Methodsmconcat :: [Lifetime] -> Lifetime # # Since: base-4.4.0.0 Instance detailsDefined in GHC.Event.Internal Methodsmappend :: Event -> Event -> Event #mconcat :: [Event] -> Event # Monoid [a] # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsmempty :: [a] #mappend :: [a] -> [a] -> [a] #mconcat :: [[a]] -> [a] # Semigroup a => Monoid (Maybe a) # 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.Since: base-2.1 Instance detailsDefined in GHC.Base Methodsmempty :: Maybe a #mappend :: Maybe a -> Maybe a -> Maybe a #mconcat :: [Maybe a] -> Maybe a # Monoid a => Monoid (IO a) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methodsmempty :: IO a #mappend :: IO a -> IO a -> IO a #mconcat :: [IO a] -> IO a # Monoid p => Monoid (Par1 p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methodsmempty :: Par1 p #mappend :: Par1 p -> Par1 p -> Par1 p #mconcat :: [Par1 p] -> Par1 p # Monoid a => Monoid (Down a) # Since: base-4.11.0.0 Instance detailsDefined in Data.Ord Methodsmempty :: Down a #mappend :: Down a -> Down a -> Down a #mconcat :: [Down a] -> Down a # Num a => Monoid (Product a) # Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methodsmappend :: Product a -> Product a -> Product a #mconcat :: [Product a] -> Product a # Num a => Monoid (Sum a) # Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methodsmempty :: Sum a #mappend :: Sum a -> Sum a -> Sum a #mconcat :: [Sum a] -> Sum a # Monoid (Endo a) # Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methodsmempty :: Endo a #mappend :: Endo a -> Endo a -> Endo a #mconcat :: [Endo a] -> Endo a # Monoid a => Monoid (Dual a) # Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methodsmempty :: Dual a #mappend :: Dual a -> Dual a -> Dual a #mconcat :: [Dual a] -> Dual a # Monoid (Last a) # Since: base-2.1 Instance detailsDefined in Data.Monoid Methodsmempty :: Last a #mappend :: Last a -> Last a -> Last a #mconcat :: [Last a] -> Last a # Monoid (First a) # Since: base-2.1 Instance detailsDefined in Data.Monoid Methodsmempty :: First a #mappend :: First a -> First a -> First a #mconcat :: [First a] -> First a # Monoid a => Monoid (Identity a) # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Identity Methodsmappend :: Identity a -> Identity a -> Identity a #mconcat :: [Identity a] -> Identity a # Semigroup a => Monoid (Option a) # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsmappend :: Option a -> Option a -> Option a #mconcat :: [Option a] -> Option a # Monoid m => Monoid (WrappedMonoid m) # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsmconcat :: [WrappedMonoid m] -> WrappedMonoid m # (Ord a, Bounded a) => Monoid (Max a) # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsmempty :: Max a #mappend :: Max a -> Max a -> Max a #mconcat :: [Max a] -> Max a # (Ord a, Bounded a) => Monoid (Min a) # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsmempty :: Min a #mappend :: Min a -> Min a -> Min a #mconcat :: [Min a] -> Min a # # Instance detailsDefined in Data.Functor.Contravariant Methodsmappend :: Equivalence a -> Equivalence a -> Equivalence a #mconcat :: [Equivalence a] -> Equivalence a # # Instance detailsDefined in Data.Functor.Contravariant Methodsmappend :: Comparison a -> Comparison a -> Comparison a #mconcat :: [Comparison a] -> Comparison a # # Instance detailsDefined in Data.Functor.Contravariant Methodsmappend :: Predicate a -> Predicate a -> Predicate a #mconcat :: [Predicate a] -> Predicate a # Monoid b => Monoid (a -> b) # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsmempty :: a -> b #mappend :: (a -> b) -> (a -> b) -> a -> b #mconcat :: [a -> b] -> a -> b # Monoid (U1 p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methodsmempty :: U1 p #mappend :: U1 p -> U1 p -> U1 p #mconcat :: [U1 p] -> U1 p # (Monoid a, Monoid b) => Monoid (a, b) # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsmempty :: (a, b) #mappend :: (a, b) -> (a, b) -> (a, b) #mconcat :: [(a, b)] -> (a, b) # Monoid a => Monoid (ST s a) # Since: base-4.11.0.0 Instance detailsDefined in GHC.ST Methodsmempty :: ST s a #mappend :: ST s a -> ST s a -> ST s a #mconcat :: [ST s a] -> ST s a # Monoid (Proxy s) # Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methodsmempty :: Proxy s #mappend :: Proxy s -> Proxy s -> Proxy s #mconcat :: [Proxy s] -> Proxy s # Monoid a => Monoid (Op a b) # Instance detailsDefined in Data.Functor.Contravariant Methodsmempty :: Op a b #mappend :: Op a b -> Op a b -> Op a b #mconcat :: [Op a b] -> Op a b # Monoid (f p) => Monoid (Rec1 f p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methodsmempty :: Rec1 f p #mappend :: Rec1 f p -> Rec1 f p -> Rec1 f p #mconcat :: [Rec1 f p] -> Rec1 f p # (Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsmempty :: (a, b, c) #mappend :: (a, b, c) -> (a, b, c) -> (a, b, c) #mconcat :: [(a, b, c)] -> (a, b, c) # Alternative f => Monoid (Alt f a) # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methodsmempty :: Alt f a #mappend :: Alt f a -> Alt f a -> Alt f a #mconcat :: [Alt f a] -> Alt f a # (Applicative f, Monoid a) => Monoid (Ap f a) # Since: base-4.12.0.0 Instance detailsDefined in Data.Monoid Methodsmempty :: Ap f a #mappend :: Ap f a -> Ap f a -> Ap f a #mconcat :: [Ap f a] -> Ap f a # Monoid a => Monoid (Const a b) # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Const Methodsmempty :: Const a b #mappend :: Const a b -> Const a b -> Const a b #mconcat :: [Const a b] -> Const a b # Monoid c => Monoid (K1 i c p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methodsmempty :: K1 i c p #mappend :: K1 i c p -> K1 i c p -> K1 i c p #mconcat :: [K1 i c p] -> K1 i c p # (Monoid (f p), Monoid (g p)) => Monoid ((f :*: g) p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methodsmempty :: (f :*: g) p #mappend :: (f :*: g) p -> (f :*: g) p -> (f :*: g) p #mconcat :: [(f :*: g) p] -> (f :*: g) p # (Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsmempty :: (a, b, c, d) #mappend :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) #mconcat :: [(a, b, c, d)] -> (a, b, c, d) # Monoid (f p) => Monoid (M1 i c f p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methodsmempty :: M1 i c f p #mappend :: M1 i c f p -> M1 i c f p -> M1 i c f p #mconcat :: [M1 i c f p] -> M1 i c f p # Monoid (f (g p)) => Monoid ((f :.: g) p) # Since: base-4.12.0.0 Instance detailsDefined in GHC.Generics Methodsmempty :: (f :.: g) p #mappend :: (f :.: g) p -> (f :.: g) p -> (f :.: g) p #mconcat :: [(f :.: g) p] -> (f :.: g) p # (Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsmempty :: (a, b, c, d, e) #mappend :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) #mconcat :: [(a, b, c, d, e)] -> (a, b, c, d, e) # data Opaque # Constructors  forall a. O a type String = [Char] # A String is a list of characters. String constants in Haskell are values of type String. data NonEmpty a # Non-empty (and non-strict) list type. Since: base-4.9.0.0 Constructors  a :| [a] infixr 5 #### Instances Instances details  # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(>>=) :: NonEmpty a -> (a -> NonEmpty b) -> NonEmpty b #(>>) :: NonEmpty a -> NonEmpty b -> NonEmpty b #return :: a -> NonEmpty a # # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methodsfmap :: (a -> b) -> NonEmpty a -> NonEmpty b #(<$) :: a -> NonEmpty b -> NonEmpty a # # Since: base-4.9.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> NonEmpty a) -> NonEmpty a # # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methodspure :: a -> NonEmpty a #(<*>) :: NonEmpty (a -> b) -> NonEmpty a -> NonEmpty b #liftA2 :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c #(*>) :: NonEmpty a -> NonEmpty b -> NonEmpty b #(<*) :: NonEmpty a -> NonEmpty b -> NonEmpty a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Foldable Methodsfold :: Monoid m => NonEmpty m -> m #foldMap :: Monoid m => (a -> m) -> NonEmpty a -> m #foldMap' :: Monoid m => (a -> m) -> NonEmpty a -> m #foldr :: (a -> b -> b) -> b -> NonEmpty a -> b #foldr' :: (a -> b -> b) -> b -> NonEmpty a -> b #foldl :: (b -> a -> b) -> b -> NonEmpty a -> b #foldl' :: (b -> a -> b) -> b -> NonEmpty a -> b #foldr1 :: (a -> a -> a) -> NonEmpty a -> a #foldl1 :: (a -> a -> a) -> NonEmpty a -> a #toList :: NonEmpty a -> [a] #null :: NonEmpty a -> Bool #length :: NonEmpty a -> Int #elem :: Eq a => a -> NonEmpty a -> Bool #maximum :: Ord a => NonEmpty a -> a #minimum :: Ord a => NonEmpty a -> a #sum :: Num a => NonEmpty a -> a #product :: Num a => NonEmpty a -> a # # Since: base-4.9.0.0 Instance detailsDefined in Data.Traversable Methodstraverse :: Applicative f => (a -> f b) -> NonEmpty a -> f (NonEmpty b) #sequenceA :: Applicative f => NonEmpty (f a) -> f (NonEmpty a) #mapM :: Monad m => (a -> m b) -> NonEmpty a -> m (NonEmpty b) #sequence :: Monad m => NonEmpty (m a) -> m (NonEmpty a) # # Since: base-4.9.0.0 Instance detailsDefined in Control.Monad.Zip Methodsmzip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b) #mzipWith :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c #munzip :: NonEmpty (a, b) -> (NonEmpty a, NonEmpty b) # # Since: base-4.10.0.0 Instance detailsDefined in Data.Functor.Classes MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> NonEmpty a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [NonEmpty a] -> ShowS # # Since: base-4.10.0.0 Instance detailsDefined in Data.Functor.Classes MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (NonEmpty a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [NonEmpty a] #liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (NonEmpty a) #liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [NonEmpty a] # # Since: base-4.10.0.0 Instance detailsDefined in Data.Functor.Classes MethodsliftCompare :: (a -> b -> Ordering) -> NonEmpty a -> NonEmpty b -> Ordering # # Since: base-4.10.0.0 Instance detailsDefined in Data.Functor.Classes MethodsliftEq :: (a -> b -> Bool) -> NonEmpty a -> NonEmpty b -> Bool # # Since: base-4.9.0.0 Instance detailsDefined in GHC.Exts Associated Typestype Item (NonEmpty a) # MethodsfromList :: [Item (NonEmpty a)] -> NonEmpty a #fromListN :: Int -> [Item (NonEmpty a)] -> NonEmpty a #toList :: NonEmpty a -> [Item (NonEmpty a)] # Eq a => Eq (NonEmpty a) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(==) :: NonEmpty a -> NonEmpty a -> Bool Source #(/=) :: NonEmpty a -> NonEmpty a -> Bool Source # Data a => Data (NonEmpty a) # Since: base-4.9.0.0 Instance detailsDefined in Data.Data Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NonEmpty a -> c (NonEmpty a) #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (NonEmpty a) #toConstr :: NonEmpty a -> Constr #dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (NonEmpty a)) #dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (NonEmpty a)) #gmapT :: (forall b. Data b => b -> b) -> NonEmpty a -> NonEmpty a #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NonEmpty a -> r #gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NonEmpty a -> r #gmapQ :: (forall d. Data d => d -> u) -> NonEmpty a -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> NonEmpty a -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> NonEmpty a -> m (NonEmpty a) #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NonEmpty a -> m (NonEmpty a) #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NonEmpty a -> m (NonEmpty a) # Ord a => Ord (NonEmpty a) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methodscompare :: NonEmpty a -> NonEmpty a -> Ordering Source #(<) :: NonEmpty a -> NonEmpty a -> Bool Source #(<=) :: NonEmpty a -> NonEmpty a -> Bool Source #(>) :: NonEmpty a -> NonEmpty a -> Bool Source #(>=) :: NonEmpty a -> NonEmpty a -> Bool Source #max :: NonEmpty a -> NonEmpty a -> NonEmpty a Source #min :: NonEmpty a -> NonEmpty a -> NonEmpty a Source # Read a => Read (NonEmpty a) # Since: base-4.11.0.0 Instance detailsDefined in GHC.Read MethodsreadsPrec :: Int -> ReadS (NonEmpty a) # Show a => Show (NonEmpty a) # Since: base-4.11.0.0 Instance detailsDefined in GHC.Show MethodsshowsPrec :: Int -> NonEmpty a -> ShowS #show :: NonEmpty a -> String #showList :: [NonEmpty a] -> ShowS # # Since: base-4.6.0.0 Instance detailsDefined in GHC.Generics Associated Typestype Rep (NonEmpty a) :: Type -> Type # Methodsfrom :: NonEmpty a -> Rep (NonEmpty a) x #to :: Rep (NonEmpty a) x -> NonEmpty a # # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: NonEmpty a -> NonEmpty a -> NonEmpty a #sconcat :: NonEmpty (NonEmpty a) -> NonEmpty a #stimes :: Integral b => b -> NonEmpty a -> NonEmpty a # # Since: base-4.6.0.0 Instance detailsDefined in GHC.Generics Associated Typestype Rep1 NonEmpty :: k -> Type # Methodsfrom1 :: forall (a :: k). NonEmpty a -> Rep1 NonEmpty a #to1 :: forall (a :: k). Rep1 NonEmpty a -> NonEmpty a # type Rep (NonEmpty a) # Instance detailsDefined in GHC.Generics type Rep (NonEmpty a) = D1 ('MetaData "NonEmpty" "GHC.Base" "base" 'False) (C1 ('MetaCons ":|" ('InfixI 'LeftAssociative 9) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [a]))) type Item (NonEmpty a) # Instance detailsDefined in GHC.Exts type Item (NonEmpty a) = a type Rep1 NonEmpty # Instance detailsDefined in GHC.Generics type Rep1 NonEmpty = D1 ('MetaData "NonEmpty" "GHC.Base" "base" 'False) (C1 ('MetaCons ":|" ('InfixI 'LeftAssociative 9) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 [])))

Monads that also support choice and failure.

Minimal complete definition

Nothing

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 = (<|>)


#### Instances

Instances details

class Applicative f => Alternative f where #

A monoid on applicative functors.

If defined, some and many should be the least solutions of the equations:

• some v = (:) <$> v <*> many v • many v = some v <|> pure [] Minimal complete definition Methods empty :: f a # The identity of <|> (<|>) :: f a -> f a -> f a infixl 3 # An associative binary operation some :: f a -> f [a] # One or more. many :: f a -> f [a] # Zero or more. #### Instances Instances details  # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsempty :: [a] #(<|>) :: [a] -> [a] -> [a] #some :: [a] -> [[a]] #many :: [a] -> [[a]] # # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsempty :: Maybe a #(<|>) :: Maybe a -> Maybe a -> Maybe a #some :: Maybe a -> Maybe [a] #many :: Maybe a -> Maybe [a] # # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methodsempty :: IO a #(<|>) :: IO a -> IO a -> IO a #some :: IO a -> IO [a] #many :: IO a -> IO [a] # # Since: base-4.6.0.0 Instance detailsDefined in Text.ParserCombinators.ReadP Methodsempty :: ReadP a #(<|>) :: ReadP a -> ReadP a -> ReadP a #some :: ReadP a -> ReadP [a] #many :: ReadP a -> ReadP [a] # # Since: base-4.6.0.0 Instance detailsDefined in Text.ParserCombinators.ReadPrec Methods(<|>) :: ReadPrec a -> ReadPrec a -> ReadPrec a #some :: ReadPrec a -> ReadPrec [a] #many :: ReadPrec a -> ReadPrec [a] # # Since: base-4.8.0.0 Instance detailsDefined in GHC.Conc.Sync Methodsempty :: STM a #(<|>) :: STM a -> STM a -> STM a #some :: STM a -> STM [a] #many :: STM a -> STM [a] # # Since: base-4.11.0.0 Instance detailsDefined in Control.Applicative Methods(<|>) :: ZipList a -> ZipList a -> ZipList a #some :: ZipList a -> ZipList [a] #many :: ZipList a -> ZipList [a] # # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsempty :: Option a #(<|>) :: Option a -> Option a -> Option a #some :: Option a -> Option [a] #many :: Option a -> Option [a] # Alternative (U1 :: Type -> Type) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsempty :: U1 a #(<|>) :: U1 a -> U1 a -> U1 a #some :: U1 a -> U1 [a] #many :: U1 a -> U1 [a] # Alternative (Proxy :: Type -> Type) # Since: base-4.9.0.0 Instance detailsDefined in Data.Proxy Methodsempty :: Proxy a #(<|>) :: Proxy a -> Proxy a -> Proxy a #some :: Proxy a -> Proxy [a] #many :: Proxy a -> Proxy [a] # # Since: base-4.6.0.0 Instance detailsDefined in Control.Arrow Methodsempty :: ArrowMonad a a0 #(<|>) :: ArrowMonad a a0 -> ArrowMonad a a0 -> ArrowMonad a a0 #some :: ArrowMonad a a0 -> ArrowMonad a [a0] #many :: ArrowMonad a a0 -> ArrowMonad a [a0] # # Since: base-2.1 Instance detailsDefined in Control.Applicative Methodsempty :: WrappedMonad m a #(<|>) :: WrappedMonad m a -> WrappedMonad m a -> WrappedMonad m a #some :: WrappedMonad m a -> WrappedMonad m [a] #many :: WrappedMonad m a -> WrappedMonad m [a] # Alternative f => Alternative (Rec1 f) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsempty :: Rec1 f a #(<|>) :: Rec1 f a -> Rec1 f a -> Rec1 f a #some :: Rec1 f a -> Rec1 f [a] #many :: Rec1 f a -> Rec1 f [a] # Alternative f => Alternative (Alt f) # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methodsempty :: Alt f a #(<|>) :: Alt f a -> Alt f a -> Alt f a #some :: Alt f a -> Alt f [a] #many :: Alt f a -> Alt f [a] # Alternative f => Alternative (Ap f) # Since: base-4.12.0.0 Instance detailsDefined in Data.Monoid Methodsempty :: Ap f a #(<|>) :: Ap f a -> Ap f a -> Ap f a #some :: Ap f a -> Ap f [a] #many :: Ap f a -> Ap f [a] # (ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) # Since: base-2.1 Instance detailsDefined in Control.Applicative Methodsempty :: WrappedArrow a b a0 #(<|>) :: WrappedArrow a b a0 -> WrappedArrow a b a0 -> WrappedArrow a b a0 #some :: WrappedArrow a b a0 -> WrappedArrow a b [a0] #many :: WrappedArrow a b a0 -> WrappedArrow a b [a0] # (Alternative f, Alternative g) => Alternative (f :*: g) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsempty :: (f :*: g) a #(<|>) :: (f :*: g) a -> (f :*: g) a -> (f :*: g) a #some :: (f :*: g) a -> (f :*: g) [a] #many :: (f :*: g) a -> (f :*: g) [a] # (Alternative f, Alternative g) => Alternative (Product f g) # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Product Methodsempty :: Product f g a #(<|>) :: Product f g a -> Product f g a -> Product f g a #some :: Product f g a -> Product f g [a] #many :: Product f g a -> Product f g [a] # Alternative f => Alternative (M1 i c f) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsempty :: M1 i c f a #(<|>) :: M1 i c f a -> M1 i c f a -> M1 i c f a #some :: M1 i c f a -> M1 i c f [a] #many :: M1 i c f a -> M1 i c f [a] # (Alternative f, Applicative g) => Alternative (f :.: g) # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsempty :: (f :.: g) a #(<|>) :: (f :.: g) a -> (f :.: g) a -> (f :.: g) a #some :: (f :.: g) a -> (f :.: g) [a] #many :: (f :.: g) a -> (f :.: g) [a] # (Alternative f, Applicative g) => Alternative (Compose f g) # Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Compose Methodsempty :: Compose f g a #(<|>) :: Compose f g a -> Compose f g a -> Compose f g a #some :: Compose f g a -> Compose f g [a] #many :: Compose f g a -> Compose f g [a] # (<**>) :: Applicative f => f a -> f (a -> b) -> f b infixl 4 # A variant of <*> with the arguments reversed. liftA :: Applicative f => (a -> b) -> f a -> f b # Lift a function to actions. This function may be used as a value for fmap in a Functor instance. liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d # Lift a ternary function to actions. (=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 # Same as >>=, but with the arguments interchanged. when :: Applicative f => Bool -> f () -> f () # Conditional execution of Applicative expressions. For example, when debug (putStrLn "Debugging") will output the string Debugging if the Boolean value debug is True, and otherwise do nothing. sequence :: Monad m => [m a] -> m [a] # Evaluate each action in the sequence from left to right, and collect the results. mapM :: Monad m => (a -> m b) -> [a] -> m [b] # mapM f is equivalent to sequence . map f. liftM :: Monad m => (a1 -> r) -> m a1 -> m r # Promote a function to a monad. liftM2 :: 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. For example, liftM2 (+) [0,1] [0,2] = [0,2,1,3] liftM2 (+) (Just 1) Nothing = Nothing liftM3 :: 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). liftM4 :: Monad m => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r # Promote a function to a monad, scanning the monadic arguments from left to right (cf. liftM2). liftM5 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r # Promote a function to a monad, scanning the monadic arguments from left to right (cf. liftM2). ap :: 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 liftMn f x1 x2 ... xn mapFB :: (elt -> lst -> lst) -> (a -> elt) -> a -> lst -> lst # ord :: Char -> Int # The fromEnum method restricted to the type Char. id :: a -> a # Identity function. id x = x const :: a -> b -> a # const x is a unary function which evaluates to x for all inputs. >>> const 42 "hello" 42  >>> map (const 42) [0..3] [42,42,42,42]  (.) :: (b -> c) -> (a -> b) -> a -> c infixr 9 # Function composition. flip :: (a -> b -> c) -> b -> a -> c # flip f takes its (first) two arguments in the reverse order of f. >>> flip (++) "hello" "world" "worldhello"  ($!) :: forall r a (b :: TYPE r). (a -> b) -> a -> b infixr 0 #

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.

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

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

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

unIO :: IO a -> State# RealWorld -> (# State# RealWorld, a #) #

getTag :: a -> Int# #

Returns the tag of a constructor application; this function is used by the deriving code for Eq, Ord and Enum.

quotInt :: Int -> Int -> Int #

remInt :: Int -> Int -> Int #

divInt :: Int -> Int -> Int #

modInt :: Int -> Int -> Int #

quotRemInt :: Int -> Int -> (Int, Int) #

divModInt :: Int -> Int -> (Int, Int) #

divModInt# :: Int# -> Int# -> (# Int#, Int# #) #

shiftL# :: Word# -> Int# -> Word# #

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

shiftRL# :: Word# -> Int# -> Word# #

Shift the argument right by the specified number of bits (which must be non-negative). The RL means "right, logical" (as opposed to RA for arithmetic) (although an arithmetic right shift wouldn't make sense for Word#)

iShiftL# :: Int# -> Int# -> Int# #

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

iShiftRA# :: Int# -> Int# -> Int# #

Shift the argument right (signed) by the specified number of bits (which must be non-negative). The RA means "right, arithmetic" (as opposed to RL for logical)

iShiftRL# :: Int# -> Int# -> Int# #

Shift the argument right (unsigned) by the specified number of bits (which must be non-negative). The RL means "right, logical" (as opposed to RA for arithmetic)

module GHC.Magic

module GHC.Types

module GHC.Prim

module GHC.Err

module GHC.Maybe