ghc-9.0.2: The GHC API

Description

Utilities related to Monad and Applicative classes Mostly for backwards compatibility.

Synopsis

# Documentation

class Functor f => Applicative (f :: Type -> Type) where Source #

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 • m1 <*> m2 = m1 >>= (x1 -> m2 >>= (x2 -> return (x1 x2))) • (*>) = (>>) (which implies that pure and <*> satisfy the applicative functor laws). Minimal complete definition pure, ((<*>) | liftA2) Methods pure :: a -> f a Source # Lift a value. (<*>) :: f (a -> b) -> f a -> f b infixl 4 Source # Sequential application. A few functors support an implementation of <*> that is more efficient than the default one. #### Example Expand Used in combination with (<$>), (<*>) can be used to build a record.

>>> data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}

>>> produceFoo :: Applicative f => f Foo

>>> produceBar :: Applicative f => f Bar
>>> produceBaz :: Applicative f => f Baz

>>> mkState :: Applicative f => f MyState
>>> mkState = MyState <$> produceFoo <*> produceBar <*> produceBaz  liftA2 :: (a -> b -> c) -> f a -> f b -> f c Source # 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 Expand >>> liftA2 (,) (Just 3) (Just 5) Just (3,5)  (*>) :: f a -> f b -> f b infixl 4 Source # Sequence actions, discarding the value of the first argument. #### Examples Expand If used in conjunction with the Applicative instance for Maybe, you can chain Maybe computations, with a possible "early return" in case of Nothing. >>> Just 2 *> Just 3 Just 3  >>> Nothing *> Just 3 Nothing  Of course a more interesting use case would be to have effectful computations instead of just returning pure values. >>> import Data.Char >>> import Text.ParserCombinators.ReadP >>> let p = string "my name is " *> munch1 isAlpha <* eof >>> readP_to_S p "my name is Simon" [("Simon","")]  (<*) :: f a -> f b -> f a infixl 4 Source # Sequence actions, discarding the value of the second argument. #### Instances Instances details  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 Source #(<*>) :: ZipList (a -> b) -> ZipList a -> ZipList b Source #liftA2 :: (a -> b -> c) -> ZipList a -> ZipList b -> ZipList c Source #(*>) :: ZipList a -> ZipList b -> ZipList b Source #(<*) :: ZipList a -> ZipList b -> ZipList a Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Complex Methodspure :: a -> Complex a Source #(<*>) :: Complex (a -> b) -> Complex a -> Complex b Source #liftA2 :: (a -> b -> c) -> Complex a -> Complex b -> Complex c Source #(*>) :: Complex a -> Complex b -> Complex b Source #(<*) :: Complex a -> Complex b -> Complex a Source # Since: base-4.8.0.0 Instance detailsDefined in Data.Functor.Identity Methodspure :: a -> Identity a Source #(<*>) :: Identity (a -> b) -> Identity a -> Identity b Source #liftA2 :: (a -> b -> c) -> Identity a -> Identity b -> Identity c Source #(*>) :: Identity a -> Identity b -> Identity b Source #(<*) :: Identity a -> Identity b -> Identity a Source # Since: base-4.8.0.0 Instance detailsDefined in Data.Monoid Methodspure :: a -> First a Source #(<*>) :: First (a -> b) -> First a -> First b Source #liftA2 :: (a -> b -> c) -> First a -> First b -> First c Source #(*>) :: First a -> First b -> First b Source #(<*) :: First a -> First b -> First a Source # Since: base-4.8.0.0 Instance detailsDefined in Data.Monoid Methodspure :: a -> Last a Source #(<*>) :: Last (a -> b) -> Last a -> Last b Source #liftA2 :: (a -> b -> c) -> Last a -> Last b -> Last c Source #(*>) :: Last a -> Last b -> Last b Source #(<*) :: Last a -> Last b -> Last a Source # Since: base-4.11.0.0 Instance detailsDefined in Data.Ord Methodspure :: a -> Down a Source #(<*>) :: Down (a -> b) -> Down a -> Down b Source #liftA2 :: (a -> b -> c) -> Down a -> Down b -> Down c Source #(*>) :: Down a -> Down b -> Down b Source #(<*) :: Down a -> Down b -> Down a Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodspure :: a -> First a Source #(<*>) :: First (a -> b) -> First a -> First b Source #liftA2 :: (a -> b -> c) -> First a -> First b -> First c Source #(*>) :: First a -> First b -> First b Source #(<*) :: First a -> First b -> First a Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodspure :: a -> Last a Source #(<*>) :: Last (a -> b) -> Last a -> Last b Source #liftA2 :: (a -> b -> c) -> Last a -> Last b -> Last c Source #(*>) :: Last a -> Last b -> Last b Source #(<*) :: Last a -> Last b -> Last a Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodspure :: a -> Max a Source #(<*>) :: Max (a -> b) -> Max a -> Max b Source #liftA2 :: (a -> b -> c) -> Max a -> Max b -> Max c Source #(*>) :: Max a -> Max b -> Max b Source #(<*) :: Max a -> Max b -> Max a Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodspure :: a -> Min a Source #(<*>) :: Min (a -> b) -> Min a -> Min b Source #liftA2 :: (a -> b -> c) -> Min a -> Min b -> Min c Source #(*>) :: Min a -> Min b -> Min b Source #(<*) :: Min a -> Min b -> Min a Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodspure :: a -> Option a Source #(<*>) :: Option (a -> b) -> Option a -> Option b Source #liftA2 :: (a -> b -> c) -> Option a -> Option b -> Option c Source #(*>) :: Option a -> Option b -> Option b Source #(<*) :: Option a -> Option b -> Option a Source # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methodspure :: a -> Dual a Source #(<*>) :: Dual (a -> b) -> Dual a -> Dual b Source #liftA2 :: (a -> b -> c) -> Dual a -> Dual b -> Dual c Source #(*>) :: Dual a -> Dual b -> Dual b Source #(<*) :: Dual a -> Dual b -> Dual a Source # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methodspure :: a -> Product a Source #(<*>) :: Product (a -> b) -> Product a -> Product b Source #liftA2 :: (a -> b -> c) -> Product a -> Product b -> Product c Source #(*>) :: Product a -> Product b -> Product b Source #(<*) :: Product a -> Product b -> Product a Source # Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methodspure :: a -> Sum a Source #(<*>) :: Sum (a -> b) -> Sum a -> Sum b Source #liftA2 :: (a -> b -> c) -> Sum a -> Sum b -> Sum c Source #(*>) :: Sum a -> Sum b -> Sum b Source #(<*) :: Sum a -> Sum b -> Sum a Source # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methodspure :: a -> NonEmpty a Source #(<*>) :: NonEmpty (a -> b) -> NonEmpty a -> NonEmpty b Source #liftA2 :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c Source #(*>) :: NonEmpty a -> NonEmpty b -> NonEmpty b Source #(<*) :: NonEmpty a -> NonEmpty b -> NonEmpty a Source # Since: base-4.8.0.0 Instance detailsDefined in GHC.Conc.Sync Methodspure :: a -> STM a Source #(<*>) :: STM (a -> b) -> STM a -> STM b Source #liftA2 :: (a -> b -> c) -> STM a -> STM b -> STM c Source #(*>) :: STM a -> STM b -> STM b Source #(<*) :: STM a -> STM b -> STM a Source # Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodspure :: a -> Par1 a Source #(<*>) :: Par1 (a -> b) -> Par1 a -> Par1 b Source #liftA2 :: (a -> b -> c) -> Par1 a -> Par1 b -> Par1 c Source #(*>) :: Par1 a -> Par1 b -> Par1 b Source #(<*) :: Par1 a -> Par1 b -> Par1 a Source # Since: base-4.5.0.0 Instance detailsDefined in Text.ParserCombinators.ReadP Methodspure :: a -> P a Source #(<*>) :: P (a -> b) -> P a -> P b Source #liftA2 :: (a -> b -> c) -> P a -> P b -> P c Source #(*>) :: P a -> P b -> P b Source #(<*) :: P a -> P b -> P a Source # Since: base-4.6.0.0 Instance detailsDefined in Text.ParserCombinators.ReadP Methodspure :: a -> ReadP a Source #(<*>) :: ReadP (a -> b) -> ReadP a -> ReadP b Source #liftA2 :: (a -> b -> c) -> ReadP a -> ReadP b -> ReadP c Source #(*>) :: ReadP a -> ReadP b -> ReadP b Source #(<*) :: ReadP a -> ReadP b -> ReadP a Source # Since: base-4.6.0.0 Instance detailsDefined in Text.ParserCombinators.ReadPrec Methodspure :: a -> ReadPrec a Source #(<*>) :: ReadPrec (a -> b) -> ReadPrec a -> ReadPrec b Source #liftA2 :: (a -> b -> c) -> ReadPrec a -> ReadPrec b -> ReadPrec c Source #(*>) :: ReadPrec a -> ReadPrec b -> ReadPrec b Source #(<*) :: ReadPrec a -> ReadPrec b -> ReadPrec a Source # Instance detailsDefined in Data.Binary.Get.Internal Methodspure :: a -> Get a Source #(<*>) :: Get (a -> b) -> Get a -> Get b Source #liftA2 :: (a -> b -> c) -> Get a -> Get b -> Get c Source #(*>) :: Get a -> Get b -> Get b Source #(<*) :: Get a -> Get b -> Get a Source # Instance detailsDefined in Data.Binary.Put Methodspure :: a -> PutM a Source #(<*>) :: PutM (a -> b) -> PutM a -> PutM b Source #liftA2 :: (a -> b -> c) -> PutM a -> PutM b -> PutM c Source #(*>) :: PutM a -> PutM b -> PutM b Source #(<*) :: PutM a -> PutM b -> PutM a Source # Instance detailsDefined in Data.ByteString.Builder.Internal Methodspure :: a -> Put a Source #(<*>) :: Put (a -> b) -> Put a -> Put b Source #liftA2 :: (a -> b -> c) -> Put a -> Put b -> Put c Source #(*>) :: Put a -> Put b -> Put b Source #(<*) :: Put a -> Put b -> Put a Source # Since: containers-0.5.4 Instance detailsDefined in Data.Sequence.Internal Methodspure :: a -> Seq a Source #(<*>) :: Seq (a -> b) -> Seq a -> Seq b Source #liftA2 :: (a -> b -> c) -> Seq a -> Seq b -> Seq c Source #(*>) :: Seq a -> Seq b -> Seq b Source #(<*) :: Seq a -> Seq b -> Seq a Source # Instance detailsDefined in Data.Tree Methodspure :: a -> Tree a Source #(<*>) :: Tree (a -> b) -> Tree a -> Tree b Source #liftA2 :: (a -> b -> c) -> Tree a -> Tree b -> Tree c Source #(*>) :: Tree a -> Tree b -> Tree b Source #(<*) :: Tree a -> Tree b -> Tree a Source # Source # Instance detailsDefined in GHC.Cmm.Monad Methodspure :: a -> PD a Source #(<*>) :: PD (a -> b) -> PD a -> PD b Source #liftA2 :: (a -> b -> c) -> PD a -> PD b -> PD c Source #(*>) :: PD a -> PD b -> PD b Source #(<*) :: PD a -> PD b -> PD a Source # Source # Instance detailsDefined in GHC.CmmToAsm.Monad Methodspure :: a -> NatM a Source #(<*>) :: NatM (a -> b) -> NatM a -> NatM b Source #liftA2 :: (a -> b -> c) -> NatM a -> NatM b -> NatM c Source #(*>) :: NatM a -> NatM b -> NatM b Source #(<*) :: NatM a -> NatM b -> NatM a Source # Source # Instance detailsDefined in GHC.CmmToLlvm.Base Methodspure :: a -> LlvmM a Source #(<*>) :: LlvmM (a -> b) -> LlvmM a -> LlvmM b Source #liftA2 :: (a -> b -> c) -> LlvmM a -> LlvmM b -> LlvmM c Source #(*>) :: LlvmM a -> LlvmM b -> LlvmM b Source #(<*) :: LlvmM a -> LlvmM b -> LlvmM a Source # Source # Instance detailsDefined in GHC.Core.Opt.Monad Methodspure :: a -> CoreM a Source #(<*>) :: CoreM (a -> b) -> CoreM a -> CoreM b Source #liftA2 :: (a -> b -> c) -> CoreM a -> CoreM b -> CoreM c Source #(*>) :: CoreM a -> CoreM b -> CoreM b Source #(<*) :: CoreM a -> CoreM b -> CoreM a Source # Source # Instance detailsDefined in GHC.Core.Opt.Simplify.Monad Methodspure :: a -> SimplM a Source #(<*>) :: SimplM (a -> b) -> SimplM a -> SimplM b Source #liftA2 :: (a -> b -> c) -> SimplM a -> SimplM b -> SimplM c Source #(*>) :: SimplM a -> SimplM b -> SimplM b Source #(<*) :: SimplM a -> SimplM b -> SimplM a Source # Source # Instance detailsDefined in GHC.Core.Unify Methodspure :: a -> UnifyResultM a Source #(<*>) :: UnifyResultM (a -> b) -> UnifyResultM a -> UnifyResultM b Source #liftA2 :: (a -> b -> c) -> UnifyResultM a -> UnifyResultM b -> UnifyResultM c Source # Source # Instance detailsDefined in GHC.Data.Pair Methodspure :: a -> Pair a Source #(<*>) :: Pair (a -> b) -> Pair a -> Pair b Source #liftA2 :: (a -> b -> c) -> Pair a -> Pair b -> Pair c Source #(*>) :: Pair a -> Pair b -> Pair b Source #(<*) :: Pair a -> Pair b -> Pair a Source # Source # Instance detailsDefined in GHC.Driver.Monad Methodspure :: a -> Ghc a Source #(<*>) :: Ghc (a -> b) -> Ghc a -> Ghc b Source #liftA2 :: (a -> b -> c) -> Ghc a -> Ghc b -> Ghc c Source #(*>) :: Ghc a -> Ghc b -> Ghc b Source #(<*) :: Ghc a -> Ghc b -> Ghc a Source # Source # Instance detailsDefined in GHC.Driver.Pipeline.Monad Methodspure :: a -> CompPipeline a Source #(<*>) :: CompPipeline (a -> b) -> CompPipeline a -> CompPipeline b Source #liftA2 :: (a -> b -> c) -> CompPipeline a -> CompPipeline b -> CompPipeline c Source # Source # Instance detailsDefined in GHC.Driver.Types Methodspure :: a -> Hsc a Source #(<*>) :: Hsc (a -> b) -> Hsc a -> Hsc b Source #liftA2 :: (a -> b -> c) -> Hsc a -> Hsc b -> Hsc c Source #(*>) :: Hsc a -> Hsc b -> Hsc b Source #(<*) :: Hsc a -> Hsc b -> Hsc a Source # Source # Product is an "or" on falliblity---the combined match result is infallible only if the left and right argument match results both were.This is useful for combining a bunch of alternatives together and then getting the overall falliblity of the entire group. See mkDataConCase for an example. Instance detailsDefined in GHC.HsToCore.Monad Methodspure :: a -> MatchResult a Source #(<*>) :: MatchResult (a -> b) -> MatchResult a -> MatchResult b Source #liftA2 :: (a -> b -> c) -> MatchResult a -> MatchResult b -> MatchResult c Source #(*>) :: MatchResult a -> MatchResult b -> MatchResult b Source #(<*) :: MatchResult a -> MatchResult b -> MatchResult a Source # Source # Instance detailsDefined in GHC.Parser.Lexer Methodspure :: a -> P a Source #(<*>) :: P (a -> b) -> P a -> P b Source #liftA2 :: (a -> b -> c) -> P a -> P b -> P c Source #(*>) :: P a -> P b -> P b Source #(<*) :: P a -> P b -> P a Source # Source # Instance detailsDefined in GHC.Parser.PostProcess Methodspure :: a -> PV a Source #(<*>) :: PV (a -> b) -> PV a -> PV b Source #liftA2 :: (a -> b -> c) -> PV a -> PV b -> PV c Source #(*>) :: PV a -> PV b -> PV b Source #(<*) :: PV a -> PV b -> PV a Source # Source # Instance detailsDefined in GHC.Rename.Pat Methodspure :: a -> CpsRn a Source #(<*>) :: CpsRn (a -> b) -> CpsRn a -> CpsRn b Source #liftA2 :: (a -> b -> c) -> CpsRn a -> CpsRn b -> CpsRn c Source #(*>) :: CpsRn a -> CpsRn b -> CpsRn b Source #(<*) :: CpsRn a -> CpsRn b -> CpsRn a Source # Source # Instance detailsDefined in GHC.Stg.Lift.Monad Methodspure :: a -> LiftM a Source #(<*>) :: LiftM (a -> b) -> LiftM a -> LiftM b Source #liftA2 :: (a -> b -> c) -> LiftM a -> LiftM b -> LiftM c Source #(*>) :: LiftM a -> LiftM b -> LiftM b Source #(<*) :: LiftM a -> LiftM b -> LiftM a Source # Source # Instance detailsDefined in GHC.StgToCmm.ExtCode Methodspure :: a -> CmmParse a Source #(<*>) :: CmmParse (a -> b) -> CmmParse a -> CmmParse b Source #liftA2 :: (a -> b -> c) -> CmmParse a -> CmmParse b -> CmmParse c Source #(*>) :: CmmParse a -> CmmParse b -> CmmParse b Source #(<*) :: CmmParse a -> CmmParse b -> CmmParse a Source # Source # Instance detailsDefined in GHC.StgToCmm.Monad Methodspure :: a -> FCode a Source #(<*>) :: FCode (a -> b) -> FCode a -> FCode b Source #liftA2 :: (a -> b -> c) -> FCode a -> FCode b -> FCode c Source #(*>) :: FCode a -> FCode b -> FCode b Source #(<*) :: FCode a -> FCode b -> FCode a Source # Source # Instance detailsDefined in GHC.Tc.Solver.Monad Methodspure :: a -> TcS a Source #(<*>) :: TcS (a -> b) -> TcS a -> TcS b Source #liftA2 :: (a -> b -> c) -> TcS a -> TcS b -> TcS c Source #(*>) :: TcS a -> TcS b -> TcS b Source #(<*) :: TcS a -> TcS b -> TcS a Source # Source # Instance detailsDefined in GHC.Tc.Types Methodspure :: a -> TcPluginM a Source #(<*>) :: TcPluginM (a -> b) -> TcPluginM a -> TcPluginM b Source #liftA2 :: (a -> b -> c) -> TcPluginM a -> TcPluginM b -> TcPluginM c Source #(*>) :: TcPluginM a -> TcPluginM b -> TcPluginM b Source #(<*) :: TcPluginM a -> TcPluginM b -> TcPluginM a Source # Source # Instance detailsDefined in GHC.Tc.Utils.Unify Methodspure :: a -> MetaTyVarUpdateResult a Source #liftA2 :: (a -> b -> c) -> MetaTyVarUpdateResult a -> MetaTyVarUpdateResult b -> MetaTyVarUpdateResult c Source # Source # Instance detailsDefined in GHC.Types.Unique.Supply Methodspure :: a -> UniqSM a Source #(<*>) :: UniqSM (a -> b) -> UniqSM a -> UniqSM b Source #liftA2 :: (a -> b -> c) -> UniqSM a -> UniqSM b -> UniqSM c Source #(*>) :: UniqSM a -> UniqSM b -> UniqSM b Source #(<*) :: UniqSM a -> UniqSM b -> UniqSM a Source # Since: base-2.1 Instance detailsDefined in GHC.Base Methodspure :: a -> IO a Source #(<*>) :: IO (a -> b) -> IO a -> IO b Source #liftA2 :: (a -> b -> c) -> IO a -> IO b -> IO c Source #(*>) :: IO a -> IO b -> IO b Source #(<*) :: IO a -> IO b -> IO a Source # Instance detailsDefined in Language.Haskell.TH.Syntax Methodspure :: a -> Q a Source #(<*>) :: Q (a -> b) -> Q a -> Q b Source #liftA2 :: (a -> b -> c) -> Q a -> Q b -> Q c Source #(*>) :: Q a -> Q b -> Q b Source #(<*) :: Q a -> Q b -> Q a Source # Instance detailsDefined in System.Console.Terminfo.Base Methodspure :: a -> Capability a Source #(<*>) :: Capability (a -> b) -> Capability a -> Capability b Source #liftA2 :: (a -> b -> c) -> Capability a -> Capability b -> Capability c Source #(*>) :: Capability a -> Capability b -> Capability b Source #(<*) :: Capability a -> Capability b -> Capability a Source # Since: base-2.1 Instance detailsDefined in GHC.Base Methodspure :: a -> Maybe a Source #(<*>) :: Maybe (a -> b) -> Maybe a -> Maybe b Source #liftA2 :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c Source #(*>) :: Maybe a -> Maybe b -> Maybe b Source #(<*) :: Maybe a -> Maybe b -> Maybe a Source # Applicative Solo Since: base-4.15 Instance detailsDefined in GHC.Base Methodspure :: a -> Solo a Source #(<*>) :: Solo (a -> b) -> Solo a -> Solo b Source #liftA2 :: (a -> b -> c) -> Solo a -> Solo b -> Solo c Source #(*>) :: Solo a -> Solo b -> Solo b Source #(<*) :: Solo a -> Solo b -> Solo a Source # Since: base-2.1 Instance detailsDefined in GHC.Base Methodspure :: a -> [a] Source #(<*>) :: [a -> b] -> [a] -> [b] Source #liftA2 :: (a -> b -> c) -> [a] -> [b] -> [c] Source #(*>) :: [a] -> [b] -> [b] Source #(<*) :: [a] -> [b] -> [a] Source # Monad m => Applicative (WrappedMonad m) Since: base-2.1 Instance detailsDefined in Control.Applicative Methodspure :: a -> WrappedMonad m a Source #(<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b Source #liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c Source #(*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b Source #(<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a Source # Arrow a => Applicative (ArrowMonad a) Since: base-4.6.0.0 Instance detailsDefined in Control.Arrow Methodspure :: a0 -> ArrowMonad a a0 Source #(<*>) :: ArrowMonad a (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b Source #liftA2 :: (a0 -> b -> c) -> ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a c Source #(*>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b Source #(<*) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a a0 Source # Since: base-3.0 Instance detailsDefined in Data.Either Methodspure :: a -> Either e a Source #(<*>) :: Either e (a -> b) -> Either e a -> Either e b Source #liftA2 :: (a -> b -> c) -> Either e a -> Either e b -> Either e c Source #(*>) :: Either e a -> Either e b -> Either e b Source #(<*) :: Either e a -> Either e b -> Either e a Source # Applicative (Proxy :: Type -> Type) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methodspure :: a -> Proxy a Source #(<*>) :: Proxy (a -> b) -> Proxy a -> Proxy b Source #liftA2 :: (a -> b -> c) -> Proxy a -> Proxy b -> Proxy c Source #(*>) :: Proxy a -> Proxy b -> Proxy b Source #(<*) :: Proxy a -> Proxy b -> Proxy a Source # Applicative (U1 :: Type -> Type) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodspure :: a -> U1 a Source #(<*>) :: U1 (a -> b) -> U1 a -> U1 b Source #liftA2 :: (a -> b -> c) -> U1 a -> U1 b -> U1 c Source #(*>) :: U1 a -> U1 b -> U1 b Source #(<*) :: U1 a -> U1 b -> U1 a Source # Since: base-4.4.0.0 Instance detailsDefined in GHC.ST Methodspure :: a -> ST s a Source #(<*>) :: ST s (a -> b) -> ST s a -> ST s b Source #liftA2 :: (a -> b -> c) -> ST s a -> ST s b -> ST s c Source #(*>) :: ST s a -> ST s b -> ST s b Source #(<*) :: ST s a -> ST s b -> ST s a Source # Applicative (SetM s) Instance detailsDefined in Data.Graph Methodspure :: a -> SetM s a Source #(<*>) :: SetM s (a -> b) -> SetM s a -> SetM s b Source #liftA2 :: (a -> b -> c) -> SetM s a -> SetM s b -> SetM s c Source #(*>) :: SetM s a -> SetM s b -> SetM s b Source #(<*) :: SetM s a -> SetM s b -> SetM s a Source # Applicative (RegM freeRegs) Source # Instance detailsDefined in GHC.CmmToAsm.Reg.Linear.State Methodspure :: a -> RegM freeRegs a Source #(<*>) :: RegM freeRegs (a -> b) -> RegM freeRegs a -> RegM freeRegs b Source #liftA2 :: (a -> b -> c) -> RegM freeRegs a -> RegM freeRegs b -> RegM freeRegs c Source #(*>) :: RegM freeRegs a -> RegM freeRegs b -> RegM freeRegs b Source #(<*) :: RegM freeRegs a -> RegM freeRegs b -> RegM freeRegs a Source # Source # Instance detailsDefined in GHC.Data.IOEnv Methodspure :: a -> IOEnv m a Source #(<*>) :: IOEnv m (a -> b) -> IOEnv m a -> IOEnv m b Source #liftA2 :: (a -> b -> c) -> IOEnv m a -> IOEnv m b -> IOEnv m c Source #(*>) :: IOEnv m a -> IOEnv m b -> IOEnv m b Source #(<*) :: IOEnv m a -> IOEnv m b -> IOEnv m a Source # Applicative (MaybeErr err) Source # Instance detailsDefined in GHC.Data.Maybe Methodspure :: a -> MaybeErr err a Source #(<*>) :: MaybeErr err (a -> b) -> MaybeErr err a -> MaybeErr err b Source #liftA2 :: (a -> b -> c) -> MaybeErr err a -> MaybeErr err b -> MaybeErr err c Source #(*>) :: MaybeErr err a -> MaybeErr err b -> MaybeErr err b Source #(<*) :: MaybeErr err a -> MaybeErr err b -> MaybeErr err a Source # Source # Instance detailsDefined in GHC.Driver.CmdLine Methodspure :: a -> CmdLineP s a Source #(<*>) :: CmdLineP s (a -> b) -> CmdLineP s a -> CmdLineP s b Source #liftA2 :: (a -> b -> c) -> CmdLineP s a -> CmdLineP s b -> CmdLineP s c Source #(*>) :: CmdLineP s a -> CmdLineP s b -> CmdLineP s b Source #(<*) :: CmdLineP s a -> CmdLineP s b -> CmdLineP s a Source # Monad m => Applicative (EwM m) Source # Instance detailsDefined in GHC.Driver.CmdLine Methodspure :: a -> EwM m a Source #(<*>) :: EwM m (a -> b) -> EwM m a -> EwM m b Source #liftA2 :: (a -> b -> c) -> EwM m a -> EwM m b -> EwM m c Source #(*>) :: EwM m a -> EwM m b -> EwM m b Source #(<*) :: EwM m a -> EwM m b -> EwM m a Source # Applicative m => Applicative (GhcT m) Source # Instance detailsDefined in GHC.Driver.Monad Methodspure :: a -> GhcT m a Source #(<*>) :: GhcT m (a -> b) -> GhcT m a -> GhcT m b Source #liftA2 :: (a -> b -> c) -> GhcT m a -> GhcT m b -> GhcT m c Source #(*>) :: GhcT m a -> GhcT m b -> GhcT m b Source #(<*) :: GhcT m a -> GhcT m b -> GhcT m a Source # Source # Instance detailsDefined in GHC.Utils.Monad.State Methodspure :: a -> State s a Source #(<*>) :: State s (a -> b) -> State s a -> State s b Source #liftA2 :: (a -> b -> c) -> State s a -> State s b -> State s c Source #(*>) :: State s a -> State s b -> State s b Source #(<*) :: State s a -> State s b -> State s a Source # Applicative m => Applicative (ListT m) Instance detailsDefined in Control.Monad.Trans.List Methodspure :: a -> ListT m a Source #(<*>) :: ListT m (a -> b) -> ListT m a -> ListT m b Source #liftA2 :: (a -> b -> c) -> ListT m a -> ListT m b -> ListT m c Source #(*>) :: ListT m a -> ListT m b -> ListT m b Source #(<*) :: ListT m a -> ListT m b -> ListT m a Source # (Functor m, Monad m) => Applicative (MaybeT m) Instance detailsDefined in Control.Monad.Trans.Maybe Methodspure :: a -> MaybeT m a Source #(<*>) :: MaybeT m (a -> b) -> MaybeT m a -> MaybeT m b Source #liftA2 :: (a -> b -> c) -> MaybeT m a -> MaybeT m b -> MaybeT m c Source #(*>) :: MaybeT m a -> MaybeT m b -> MaybeT m b Source #(<*) :: MaybeT m a -> MaybeT m b -> MaybeT m a Source # 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) Source #(<*>) :: (a, a0 -> b) -> (a, a0) -> (a, b) Source #liftA2 :: (a0 -> b -> c) -> (a, a0) -> (a, b) -> (a, c) Source #(*>) :: (a, a0) -> (a, b) -> (a, b) Source #(<*) :: (a, a0) -> (a, b) -> (a, a0) Source # Arrow a => Applicative (WrappedArrow a b) Since: base-2.1 Instance detailsDefined in Control.Applicative Methodspure :: a0 -> WrappedArrow a b a0 Source #(<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 Source #liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c Source #(*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 Source #(<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 Source # Applicative m => Applicative (Kleisli m a) Since: base-4.14.0.0 Instance detailsDefined in Control.Arrow Methodspure :: a0 -> Kleisli m a a0 Source #(<*>) :: Kleisli m a (a0 -> b) -> Kleisli m a a0 -> Kleisli m a b Source #liftA2 :: (a0 -> b -> c) -> Kleisli m a a0 -> Kleisli m a b -> Kleisli m a c Source #(*>) :: Kleisli m a a0 -> Kleisli m a b -> Kleisli m a b Source #(<*) :: Kleisli m a a0 -> Kleisli m a b -> Kleisli m a a0 Source # Monoid m => Applicative (Const m :: Type -> Type) Since: base-2.0.1 Instance detailsDefined in Data.Functor.Const Methodspure :: a -> Const m a Source #(<*>) :: Const m (a -> b) -> Const m a -> Const m b Source #liftA2 :: (a -> b -> c) -> Const m a -> Const m b -> Const m c Source #(*>) :: Const m a -> Const m b -> Const m b Source #(<*) :: Const m a -> Const m b -> Const m a Source # Applicative f => Applicative (Ap f) Since: base-4.12.0.0 Instance detailsDefined in Data.Monoid Methodspure :: a -> Ap f a Source #(<*>) :: Ap f (a -> b) -> Ap f a -> Ap f b Source #liftA2 :: (a -> b -> c) -> Ap f a -> Ap f b -> Ap f c Source #(*>) :: Ap f a -> Ap f b -> Ap f b Source #(<*) :: Ap f a -> Ap f b -> Ap f a Source # Applicative f => Applicative (Alt f) Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methodspure :: a -> Alt f a Source #(<*>) :: Alt f (a -> b) -> Alt f a -> Alt f b Source #liftA2 :: (a -> b -> c) -> Alt f a -> Alt f b -> Alt f c Source #(*>) :: Alt f a -> Alt f b -> Alt f b Source #(<*) :: Alt f a -> Alt f b -> Alt f a Source # Applicative f => Applicative (Rec1 f) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodspure :: a -> Rec1 f a Source #(<*>) :: Rec1 f (a -> b) -> Rec1 f a -> Rec1 f b Source #liftA2 :: (a -> b -> c) -> Rec1 f a -> Rec1 f b -> Rec1 f c Source #(*>) :: Rec1 f a -> Rec1 f b -> Rec1 f b Source #(<*) :: Rec1 f a -> Rec1 f b -> Rec1 f a Source # (Applicative f, Monad f) => Applicative (WhenMissing f x) Equivalent to ReaderT k (ReaderT x (MaybeT f)).Since: containers-0.5.9 Instance detailsDefined in Data.IntMap.Internal Methodspure :: a -> WhenMissing f x a Source #(<*>) :: WhenMissing f x (a -> b) -> WhenMissing f x a -> WhenMissing f x b Source #liftA2 :: (a -> b -> c) -> WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x c Source #(*>) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x b Source #(<*) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x a Source # Monad m => Applicative (Stream m a) Source # Instance detailsDefined in GHC.Data.Stream Methodspure :: a0 -> Stream m a a0 Source #(<*>) :: Stream m a (a0 -> b) -> Stream m a a0 -> Stream m a b Source #liftA2 :: (a0 -> b -> c) -> Stream m a a0 -> Stream m a b -> Stream m a c Source #(*>) :: Stream m a a0 -> Stream m a b -> Stream m a b Source #(<*) :: Stream m a a0 -> Stream m a b -> Stream m a a0 Source # (Functor m, Monad m) => Applicative (ErrorT e m) Instance detailsDefined in Control.Monad.Trans.Error Methodspure :: a -> ErrorT e m a Source #(<*>) :: ErrorT e m (a -> b) -> ErrorT e m a -> ErrorT e m b Source #liftA2 :: (a -> b -> c) -> ErrorT e m a -> ErrorT e m b -> ErrorT e m c Source #(*>) :: ErrorT e m a -> ErrorT e m b -> ErrorT e m b Source #(<*) :: ErrorT e m a -> ErrorT e m b -> ErrorT e m a Source # (Functor m, Monad m) => Applicative (ExceptT e m) Instance detailsDefined in Control.Monad.Trans.Except Methodspure :: a -> ExceptT e m a Source #(<*>) :: ExceptT e m (a -> b) -> ExceptT e m a -> ExceptT e m b Source #liftA2 :: (a -> b -> c) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c Source #(*>) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m b Source #(<*) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m a Source # Instance detailsDefined in Control.Monad.Trans.Identity Methodspure :: a -> IdentityT m a Source #(<*>) :: IdentityT m (a -> b) -> IdentityT m a -> IdentityT m b Source #liftA2 :: (a -> b -> c) -> IdentityT m a -> IdentityT m b -> IdentityT m c Source #(*>) :: IdentityT m a -> IdentityT m b -> IdentityT m b Source #(<*) :: IdentityT m a -> IdentityT m b -> IdentityT m a Source # Applicative m => Applicative (ReaderT r m) Instance detailsDefined in Control.Monad.Trans.Reader Methodspure :: a -> ReaderT r m a Source #(<*>) :: ReaderT r m (a -> b) -> ReaderT r m a -> ReaderT r m b Source #liftA2 :: (a -> b -> c) -> ReaderT r m a -> ReaderT r m b -> ReaderT r m c Source #(*>) :: ReaderT r m a -> ReaderT r m b -> ReaderT r m b Source #(<*) :: ReaderT r m a -> ReaderT r m b -> ReaderT r m a Source # (Functor m, Monad m) => Applicative (StateT s m) Instance detailsDefined in Control.Monad.Trans.State.Lazy Methodspure :: a -> StateT s m a Source #(<*>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b Source #liftA2 :: (a -> b -> c) -> StateT s m a -> StateT s m b -> StateT s m c Source #(*>) :: StateT s m a -> StateT s m b -> StateT s m b Source #(<*) :: StateT s m a -> StateT s m b -> StateT s m a Source # (Functor m, Monad m) => Applicative (StateT s m) Instance detailsDefined in Control.Monad.Trans.State.Strict Methodspure :: a -> StateT s m a Source #(<*>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b Source #liftA2 :: (a -> b -> c) -> StateT s m a -> StateT s m b -> StateT s m c Source #(*>) :: StateT s m a -> StateT s m b -> StateT s m b Source #(<*) :: StateT s m a -> StateT s m b -> StateT s m a Source # (Monoid w, Applicative m) => Applicative (WriterT w m) Instance detailsDefined in Control.Monad.Trans.Writer.Lazy Methodspure :: a -> WriterT w m a Source #(<*>) :: WriterT w m (a -> b) -> WriterT w m a -> WriterT w m b Source #liftA2 :: (a -> b -> c) -> WriterT w m a -> WriterT w m b -> WriterT w m c Source #(*>) :: WriterT w m a -> WriterT w m b -> WriterT w m b Source #(<*) :: WriterT w m a -> WriterT w m b -> WriterT w m a Source # (Monoid w, Applicative m) => Applicative (WriterT w m) Instance detailsDefined in Control.Monad.Trans.Writer.Strict Methodspure :: a -> WriterT w m a Source #(<*>) :: WriterT w m (a -> b) -> WriterT w m a -> WriterT w m b Source #liftA2 :: (a -> b -> c) -> WriterT w m a -> WriterT w m b -> WriterT w m c Source #(*>) :: WriterT w m a -> WriterT w m b -> WriterT w m b Source #(<*) :: WriterT w m a -> WriterT w m b -> WriterT w m a Source # (Monoid a, Monoid b) => Applicative ((,,) a b) Since: base-4.14.0.0 Instance detailsDefined in GHC.Base Methodspure :: a0 -> (a, b, a0) Source #(<*>) :: (a, b, a0 -> b0) -> (a, b, a0) -> (a, b, b0) Source #liftA2 :: (a0 -> b0 -> c) -> (a, b, a0) -> (a, b, b0) -> (a, b, c) Source #(*>) :: (a, b, a0) -> (a, b, b0) -> (a, b, b0) Source #(<*) :: (a, b, a0) -> (a, b, b0) -> (a, b, a0) Source # (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 Source #(<*>) :: Product f g (a -> b) -> Product f g a -> Product f g b Source #liftA2 :: (a -> b -> c) -> Product f g a -> Product f g b -> Product f g c Source #(*>) :: Product f g a -> Product f g b -> Product f g b Source #(<*) :: Product f g a -> Product f g b -> Product f g a Source # (Applicative f, Applicative g) => Applicative (f :*: g) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodspure :: a -> (f :*: g) a Source #(<*>) :: (f :*: g) (a -> b) -> (f :*: g) a -> (f :*: g) b Source #liftA2 :: (a -> b -> c) -> (f :*: g) a -> (f :*: g) b -> (f :*: g) c Source #(*>) :: (f :*: g) a -> (f :*: g) b -> (f :*: g) b Source #(<*) :: (f :*: g) a -> (f :*: g) b -> (f :*: g) a Source # 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 Source #(<*>) :: K1 i c (a -> b) -> K1 i c a -> K1 i c b Source #liftA2 :: (a -> b -> c0) -> K1 i c a -> K1 i c b -> K1 i c c0 Source #(*>) :: K1 i c a -> K1 i c b -> K1 i c b Source #(<*) :: K1 i c a -> K1 i c b -> K1 i c a Source # (Monad f, Applicative f) => Applicative (WhenMatched f x y) Equivalent to ReaderT Key (ReaderT x (ReaderT y (MaybeT f)))Since: containers-0.5.9 Instance detailsDefined in Data.IntMap.Internal Methodspure :: a -> WhenMatched f x y a Source #(<*>) :: WhenMatched f x y (a -> b) -> WhenMatched f x y a -> WhenMatched f x y b Source #liftA2 :: (a -> b -> c) -> WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y c Source #(*>) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y b Source #(<*) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y a Source # (Applicative f, Monad f) => Applicative (WhenMissing f k x) Equivalent to  ReaderT k (ReaderT x (MaybeT f)) .Since: containers-0.5.9 Instance detailsDefined in Data.Map.Internal Methodspure :: a -> WhenMissing f k x a Source #(<*>) :: WhenMissing f k x (a -> b) -> WhenMissing f k x a -> WhenMissing f k x b Source #liftA2 :: (a -> b -> c) -> WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x c Source #(*>) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x b Source #(<*) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x a Source # Applicative (ContT r m) Instance detailsDefined in Control.Monad.Trans.Cont Methodspure :: a -> ContT r m a Source #(<*>) :: ContT r m (a -> b) -> ContT r m a -> ContT r m b Source #liftA2 :: (a -> b -> c) -> ContT r m a -> ContT r m b -> ContT r m c Source #(*>) :: ContT r m a -> ContT r m b -> ContT r m b Source #(<*) :: ContT r m a -> ContT r m b -> ContT r m a Source # (Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c) Since: base-4.14.0.0 Instance detailsDefined in GHC.Base Methodspure :: a0 -> (a, b, c, a0) Source #(<*>) :: (a, b, c, a0 -> b0) -> (a, b, c, a0) -> (a, b, c, b0) Source #liftA2 :: (a0 -> b0 -> c0) -> (a, b, c, a0) -> (a, b, c, b0) -> (a, b, c, c0) Source #(*>) :: (a, b, c, a0) -> (a, b, c, b0) -> (a, b, c, b0) Source #(<*) :: (a, b, c, a0) -> (a, b, c, b0) -> (a, b, c, a0) Source # Applicative ((->) r) Since: base-2.1 Instance detailsDefined in GHC.Base Methodspure :: a -> r -> a Source #(<*>) :: (r -> (a -> b)) -> (r -> a) -> r -> b Source #liftA2 :: (a -> b -> c) -> (r -> a) -> (r -> b) -> r -> c Source #(*>) :: (r -> a) -> (r -> b) -> r -> b Source #(<*) :: (r -> a) -> (r -> b) -> r -> a Source # (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 Source #(<*>) :: Compose f g (a -> b) -> Compose f g a -> Compose f g b Source #liftA2 :: (a -> b -> c) -> Compose f g a -> Compose f g b -> Compose f g c Source #(*>) :: Compose f g a -> Compose f g b -> Compose f g b Source #(<*) :: Compose f g a -> Compose f g b -> Compose f g a Source # (Applicative f, Applicative g) => Applicative (f :.: g) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodspure :: a -> (f :.: g) a Source #(<*>) :: (f :.: g) (a -> b) -> (f :.: g) a -> (f :.: g) b Source #liftA2 :: (a -> b -> c) -> (f :.: g) a -> (f :.: g) b -> (f :.: g) c Source #(*>) :: (f :.: g) a -> (f :.: g) b -> (f :.: g) b Source #(<*) :: (f :.: g) a -> (f :.: g) b -> (f :.: g) a Source # 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 Source #(<*>) :: M1 i c f (a -> b) -> M1 i c f a -> M1 i c f b Source #liftA2 :: (a -> b -> c0) -> M1 i c f a -> M1 i c f b -> M1 i c f c0 Source #(*>) :: M1 i c f a -> M1 i c f b -> M1 i c f b Source #(<*) :: M1 i c f a -> M1 i c f b -> M1 i c f a Source # (Monad f, Applicative f) => Applicative (WhenMatched f k x y) Equivalent to  ReaderT k (ReaderT x (ReaderT y (MaybeT f))) Since: containers-0.5.9 Instance detailsDefined in Data.Map.Internal Methodspure :: a -> WhenMatched f k x y a Source #(<*>) :: WhenMatched f k x y (a -> b) -> WhenMatched f k x y a -> WhenMatched f k x y b Source #liftA2 :: (a -> b -> c) -> WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y c Source #(*>) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y b Source #(<*) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y a Source # (Functor m, Monad m) => Applicative (RWST r w s m) Instance detailsDefined in Control.Monad.Trans.RWS.CPS Methodspure :: a -> RWST r w s m a Source #(<*>) :: RWST r w s m (a -> b) -> RWST r w s m a -> RWST r w s m b Source #liftA2 :: (a -> b -> c) -> RWST r w s m a -> RWST r w s m b -> RWST r w s m c Source #(*>) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m b Source #(<*) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m a Source # (Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) Instance detailsDefined in Control.Monad.Trans.RWS.Lazy Methodspure :: a -> RWST r w s m a Source #(<*>) :: RWST r w s m (a -> b) -> RWST r w s m a -> RWST r w s m b Source #liftA2 :: (a -> b -> c) -> RWST r w s m a -> RWST r w s m b -> RWST r w s m c Source #(*>) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m b Source #(<*) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m a Source # (Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) Instance detailsDefined in Control.Monad.Trans.RWS.Strict Methodspure :: a -> RWST r w s m a Source #(<*>) :: RWST r w s m (a -> b) -> RWST r w s m a -> RWST r w s m b Source #liftA2 :: (a -> b -> c) -> RWST r w s m a -> RWST r w s m b -> RWST r w s m c Source #(*>) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m b Source #(<*) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m a Source # (<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 Source #

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 Expand Convert from a Maybe Int to a Maybe String using show: >>> show <$> Nothing
Nothing
>>> show <$> Just 3 Just "3"  Convert from an Either Int Int to an Either Int String using show: >>> show <$> Left 17
Left 17
>>> show <$> Right 17 Right "17"  Double each element of a list: >>> (*2) <$> [1,2,3]
[2,4,6]


Apply even to the second element of a pair:

>>> even <$> (2,2) (2,True)  class Monad m => MonadFix (m :: Type -> Type) where Source # 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 Source # 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. #### Instances Instances details  Since: base-4.15.0.0 Instance detailsDefined in Data.Complex Methodsmfix :: (a -> Complex a) -> Complex a Source # Since: base-4.8.0.0 Instance detailsDefined in Data.Functor.Identity Methodsmfix :: (a -> Identity a) -> Identity a Source # Since: base-4.8.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> First a) -> First a Source # Since: base-4.8.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> Last a) -> Last a Source # Since: base-4.12.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> Down a) -> Down a Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsmfix :: (a -> First a) -> First a Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsmfix :: (a -> Last a) -> Last a Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsmfix :: (a -> Max a) -> Max a Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsmfix :: (a -> Min a) -> Min a Source # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsmfix :: (a -> Option a) -> Option a Source # Since: base-4.8.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> Dual a) -> Dual a Source # Since: base-4.8.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> Product a) -> Product a Source # Since: base-4.8.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> Sum a) -> Sum a Source # Since: base-4.9.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> NonEmpty a) -> NonEmpty a Source # Since: base-4.9.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> Par1 a) -> Par1 a Source # Since: containers-0.5.11 Instance detailsDefined in Data.Sequence.Internal Methodsmfix :: (a -> Seq a) -> Seq a Source # Since: containers-0.5.11 Instance detailsDefined in Data.Tree Methodsmfix :: (a -> Tree a) -> Tree a Source # Source # Instance detailsDefined in GHC.Driver.Monad Methodsmfix :: (a -> Ghc a) -> Ghc a Source # Source # Instance detailsDefined in GHC.Types.Unique.Supply Methodsmfix :: (a -> UniqSM a) -> UniqSM a Source # Since: base-2.1 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> IO a) -> IO a Source # If the function passed to mfix inspects its argument, the resulting action will throw a FixIOException.Since: template-haskell-2.17.0.0 Instance detailsDefined in Language.Haskell.TH.Syntax Methodsmfix :: (a -> Q a) -> Q a Source # Since: base-2.1 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> Maybe a) -> Maybe a Source # MonadFix Solo Since: base-4.15 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> Solo a) -> Solo a Source # MonadFix [] Since: base-2.1 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> [a]) -> [a] Source # Since: base-4.3.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> Either e a) -> Either e a Source # MonadFix (ST s) Since: base-2.1 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> ST s a) -> ST s a Source # MonadFix m => MonadFix (ListT m) Instance detailsDefined in Control.Monad.Trans.List Methodsmfix :: (a -> ListT m a) -> ListT m a Source # MonadFix m => MonadFix (MaybeT m) Instance detailsDefined in Control.Monad.Trans.Maybe Methodsmfix :: (a -> MaybeT m a) -> MaybeT m a Source # MonadFix f => MonadFix (Ap f) Since: base-4.12.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> Ap f a) -> Ap f a Source # MonadFix f => MonadFix (Alt f) Since: base-4.8.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> Alt f a) -> Alt f a Source # MonadFix f => MonadFix (Rec1 f) Since: base-4.9.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> Rec1 f a) -> Rec1 f a Source # (MonadFix m, Error e) => MonadFix (ErrorT e m) Instance detailsDefined in Control.Monad.Trans.Error Methodsmfix :: (a -> ErrorT e m a) -> ErrorT e m a Source # MonadFix m => MonadFix (ExceptT e m) Instance detailsDefined in Control.Monad.Trans.Except Methodsmfix :: (a -> ExceptT e m a) -> ExceptT e m a Source # MonadFix m => MonadFix (IdentityT m) Instance detailsDefined in Control.Monad.Trans.Identity Methodsmfix :: (a -> IdentityT m a) -> IdentityT m a Source # MonadFix m => MonadFix (ReaderT r m) Instance detailsDefined in Control.Monad.Trans.Reader Methodsmfix :: (a -> ReaderT r m a) -> ReaderT r m a Source # MonadFix m => MonadFix (StateT s m) Instance detailsDefined in Control.Monad.Trans.State.Lazy Methodsmfix :: (a -> StateT s m a) -> StateT s m a Source # MonadFix m => MonadFix (StateT s m) Instance detailsDefined in Control.Monad.Trans.State.Strict Methodsmfix :: (a -> StateT s m a) -> StateT s m a Source # (Monoid w, MonadFix m) => MonadFix (WriterT w m) Instance detailsDefined in Control.Monad.Trans.Writer.Lazy Methodsmfix :: (a -> WriterT w m a) -> WriterT w m a Source # (Monoid w, MonadFix m) => MonadFix (WriterT w m) Instance detailsDefined in Control.Monad.Trans.Writer.Strict Methodsmfix :: (a -> WriterT w m a) -> WriterT w m a Source # (MonadFix f, MonadFix g) => MonadFix (Product f g) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Product Methodsmfix :: (a -> Product f g a) -> Product f g a Source # (MonadFix f, MonadFix g) => MonadFix (f :*: g) Since: base-4.9.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> (f :*: g) a) -> (f :*: g) a Source # MonadFix ((->) r) Since: base-2.1 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> r -> a) -> r -> a Source # MonadFix f => MonadFix (M1 i c f) Since: base-4.9.0.0 Instance detailsDefined in Control.Monad.Fix Methodsmfix :: (a -> M1 i c f a) -> M1 i c f a Source # MonadFix m => MonadFix (RWST r w s m) Instance detailsDefined in Control.Monad.Trans.RWS.CPS Methodsmfix :: (a -> RWST r w s m a) -> RWST r w s m a Source # (Monoid w, MonadFix m) => MonadFix (RWST r w s m) Instance detailsDefined in Control.Monad.Trans.RWS.Lazy Methodsmfix :: (a -> RWST r w s m a) -> RWST r w s m a Source # (Monoid w, MonadFix m) => MonadFix (RWST r w s m) Instance detailsDefined in Control.Monad.Trans.RWS.Strict Methodsmfix :: (a -> RWST r w s m a) -> RWST r w s m a Source # class Monad m => MonadIO (m :: Type -> Type) where Source # 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: • liftIO . return = return • liftIO (m >>= f) = liftIO m >>= (liftIO . f) Methods liftIO :: IO a -> m a Source # 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 Expand 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


#### Instances

Instances details

zipWith3M :: Monad m => (a -> b -> c -> m d) -> [a] -> [b] -> [c] -> m [d] Source #

zipWith3M_ :: Monad m => (a -> b -> c -> m d) -> [a] -> [b] -> [c] -> m () Source #

zipWith4M :: Monad m => (a -> b -> c -> d -> m e) -> [a] -> [b] -> [c] -> [d] -> m [e] Source #

zipWithAndUnzipM :: Monad m => (a -> b -> m (c, d)) -> [a] -> [b] -> m ([c], [d]) Source #

mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c]) Source #

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.

mapAndUnzip3M :: Monad m => (a -> m (b, c, d)) -> [a] -> m ([b], [c], [d]) Source #

mapAndUnzipM for triples

mapAndUnzip4M :: Monad m => (a -> m (b, c, d, e)) -> [a] -> m ([b], [c], [d], [e]) Source #

mapAndUnzip5M :: Monad m => (a -> m (b, c, d, e, f)) -> [a] -> m ([b], [c], [d], [e], [f]) Source #

Arguments

 :: Monad m => (acc -> x -> m (acc, y)) combining function -> acc initial state -> [x] inputs -> m (acc, [y]) final state, outputs

mapSndM :: Monad m => (b -> m c) -> [(a, b)] -> m [(a, c)] Source #

concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b] Source #

mapMaybeM :: Applicative m => (a -> m (Maybe b)) -> [a] -> m [b] Source #

Applicative version of mapMaybe

fmapMaybeM :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b) Source #

fmapEitherM :: Monad m => (a -> m b) -> (c -> m d) -> Either a c -> m (Either b d) Source #

anyM :: Monad m => (a -> m Bool) -> [a] -> m Bool Source #

Monadic version of any, aborts the computation at the first True value

allM :: Monad m => (a -> m Bool) -> [a] -> m Bool Source #

Monad version of all, aborts the computation at the first False value

orM :: Monad m => m Bool -> m Bool -> m Bool Source #

foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b Source #

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 Expand Basic usage: >>> let f a e = do { print e ; return$ e : a }
>>> foldlM f [] [0..3]
0
1
2
3
[3,2,1,0]


foldlM_ :: (Monad m, Foldable t) => (a -> b -> m a) -> a -> t b -> m () Source #

foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b Source #

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 Expand Basic usage: >>> let f i acc = do { print i ; return$ i : acc }
>>> foldrM f [] [0..3]
3
2
1
0
[0,1,2,3]


maybeMapM :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b) Source #

Monadic version of fmap specialised for Maybe

whenM :: Monad m => m Bool -> m () -> m () Source #

Monadic version of when, taking the condition in the monad

unlessM :: Monad m => m Bool -> m () -> m () Source #

Monadic version of unless, taking the condition in the monad

filterOutM :: Applicative m => (a -> m Bool) -> [a] -> m [a] Source #

Like filterM, only it reverses the sense of the test.