ghc-lib-parser-8.8.1: The GHC API, decoupled from GHC versions

Description

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

Synopsis

# Documentation

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

A functor with application, providing operations to

• embed pure expressions (pure), and
• sequence computations and combine their results (<*> and liftA2).

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

(<*>) = liftA2 id
liftA2 f x y = f <$> x <*> y Further, any definition must satisfy the following: identity pure id <*> v = v composition pure (.) <*> u <*> v <*> w = u <*> (v <*> w) homomorphism pure f <*> pure x = pure (f x) interchange u <*> pure y = pure ($ y) <*> u

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

• 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  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 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-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.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 -> 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 -> 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 -> 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 # 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.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 # 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.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 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.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.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 -> 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.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.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.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.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 # Instance detailsDefined in Data.Binary.Put Methodspure :: a -> PutM a #(<*>) :: PutM (a -> b) -> PutM a -> PutM b #liftA2 :: (a -> b -> c) -> PutM a -> PutM b -> PutM c #(*>) :: PutM a -> PutM b -> PutM b #(<*) :: PutM a -> PutM b -> PutM a # Instance detailsDefined in Data.Binary.Get.Internal Methodspure :: a -> Get a #(<*>) :: Get (a -> b) -> Get a -> Get b #liftA2 :: (a -> b -> c) -> Get a -> Get b -> Get c #(*>) :: Get a -> Get b -> Get b #(<*) :: Get a -> Get b -> Get a # Applicative Put Instance detailsDefined in Data.ByteString.Builder.Internal Methodspure :: a -> Put a #(<*>) :: Put (a -> b) -> Put a -> Put b #liftA2 :: (a -> b -> c) -> Put a -> Put b -> Put c #(*>) :: Put a -> Put b -> Put b #(<*) :: Put a -> Put b -> Put a # Instance detailsDefined in Data.Tree Methodspure :: a -> Tree a #(<*>) :: Tree (a -> b) -> Tree a -> Tree b #liftA2 :: (a -> b -> c) -> Tree a -> Tree b -> Tree c #(*>) :: Tree a -> Tree b -> Tree b #(<*) :: Tree a -> Tree b -> Tree a # Since: containers-0.5.4 Instance detailsDefined in Data.Sequence.Internal Methodspure :: a -> Seq a #(<*>) :: Seq (a -> b) -> Seq a -> Seq b #liftA2 :: (a -> b -> c) -> Seq a -> Seq b -> Seq c #(*>) :: Seq a -> Seq b -> Seq b #(<*) :: Seq a -> Seq b -> Seq a # Since: base-4.5.0.0 Instance detailsDefined in Text.ParserCombinators.ReadP Methodspure :: a -> P a #(<*>) :: P (a -> b) -> P a -> P b #liftA2 :: (a -> b -> c) -> P a -> P b -> P c #(*>) :: P a -> P b -> P b #(<*) :: P a -> P b -> P a # Source # Instance detailsDefined in Language.Haskell.TH.Syntax Methodspure :: a -> Q a #(<*>) :: Q (a -> b) -> Q a -> Q b #liftA2 :: (a -> b -> c) -> Q a -> Q b -> Q c #(*>) :: Q a -> Q b -> Q b #(<*) :: Q a -> Q b -> Q a # Source # Instance detailsDefined in Language.Haskell.TH.PprLib Methodspure :: a -> PprM a #(<*>) :: PprM (a -> b) -> PprM a -> PprM b #liftA2 :: (a -> b -> c) -> PprM a -> PprM b -> PprM c #(*>) :: PprM a -> PprM b -> PprM b #(<*) :: PprM a -> PprM b -> PprM a # Source # Instance detailsDefined in Pair Methodspure :: a -> Pair a #(<*>) :: Pair (a -> b) -> Pair a -> Pair b #liftA2 :: (a -> b -> c) -> Pair a -> Pair b -> Pair c #(*>) :: Pair a -> Pair b -> Pair b #(<*) :: Pair a -> Pair b -> Pair a # Source # Instance detailsDefined in UniqSupply Methodspure :: a -> UniqSM a #(<*>) :: UniqSM (a -> b) -> UniqSM a -> UniqSM b #liftA2 :: (a -> b -> c) -> UniqSM a -> UniqSM b -> UniqSM c #(*>) :: UniqSM a -> UniqSM b -> UniqSM b #(<*) :: UniqSM a -> UniqSM b -> UniqSM a # Source # Instance detailsDefined in CoreMonad Methodspure :: a -> CoreM a #(<*>) :: CoreM (a -> b) -> CoreM a -> CoreM b #liftA2 :: (a -> b -> c) -> CoreM a -> CoreM b -> CoreM c #(*>) :: CoreM a -> CoreM b -> CoreM b #(<*) :: CoreM a -> CoreM b -> CoreM a # Source # Instance detailsDefined in Lexer Methodspure :: a -> P a #(<*>) :: P (a -> b) -> P a -> P b #liftA2 :: (a -> b -> c) -> P a -> P b -> P c #(*>) :: P a -> P b -> P b #(<*) :: P a -> P b -> P a # Source # Instance detailsDefined in Unify Methodspure :: a -> UnifyResultM a #(<*>) :: UnifyResultM (a -> b) -> UnifyResultM a -> UnifyResultM b #liftA2 :: (a -> b -> c) -> UnifyResultM a -> UnifyResultM b -> UnifyResultM c #(*>) :: UnifyResultM a -> UnifyResultM b -> UnifyResultM b #(<*) :: UnifyResultM a -> UnifyResultM b -> UnifyResultM a # Source # Instance detailsDefined in HscTypes Methodspure :: a -> Hsc a #(<*>) :: Hsc (a -> b) -> Hsc a -> Hsc b #liftA2 :: (a -> b -> c) -> Hsc a -> Hsc b -> Hsc c #(*>) :: Hsc a -> Hsc b -> Hsc b #(<*) :: Hsc a -> Hsc b -> Hsc a # Source # Instance detailsDefined in TcRnTypes Methodspure :: a -> TcPluginM a #(<*>) :: TcPluginM (a -> b) -> TcPluginM a -> TcPluginM b #liftA2 :: (a -> b -> c) -> TcPluginM a -> TcPluginM b -> TcPluginM c #(*>) :: TcPluginM a -> TcPluginM b -> TcPluginM b #(<*) :: TcPluginM a -> TcPluginM b -> TcPluginM a # Source # Instance detailsDefined in PipelineMonad Methodspure :: a -> CompPipeline a #(<*>) :: CompPipeline (a -> b) -> CompPipeline a -> CompPipeline b #liftA2 :: (a -> b -> c) -> CompPipeline a -> CompPipeline b -> CompPipeline c #(*>) :: CompPipeline a -> CompPipeline b -> CompPipeline b #(<*) :: CompPipeline a -> CompPipeline b -> CompPipeline a # Source # Instance detailsDefined in GhcMonad Methodspure :: a -> Ghc a #(<*>) :: Ghc (a -> b) -> Ghc a -> Ghc b #liftA2 :: (a -> b -> c) -> Ghc a -> Ghc b -> Ghc c #(*>) :: Ghc a -> Ghc b -> Ghc b #(<*) :: Ghc a -> Ghc b -> Ghc 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) # 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 # 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 # 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 # (Functor m, Monad m) => Applicative (MaybeT m) Instance detailsDefined in Control.Monad.Trans.Maybe Methodspure :: a -> MaybeT m a #(<*>) :: MaybeT m (a -> b) -> MaybeT m a -> MaybeT m b #liftA2 :: (a -> b -> c) -> MaybeT m a -> MaybeT m b -> MaybeT m c #(*>) :: MaybeT m a -> MaybeT m b -> MaybeT m b #(<*) :: MaybeT m a -> MaybeT m b -> MaybeT m a # Applicative (MaybeErr err) Source # Instance detailsDefined in Maybes Methodspure :: a -> MaybeErr err a #(<*>) :: MaybeErr err (a -> b) -> MaybeErr err a -> MaybeErr err b #liftA2 :: (a -> b -> c) -> MaybeErr err a -> MaybeErr err b -> MaybeErr err c #(*>) :: MaybeErr err a -> MaybeErr err b -> MaybeErr err b #(<*) :: MaybeErr err a -> MaybeErr err b -> MaybeErr err a # Applicative (SetM s) Instance detailsDefined in Data.Graph Methodspure :: a -> SetM s a #(<*>) :: SetM s (a -> b) -> SetM s a -> SetM s b #liftA2 :: (a -> b -> c) -> SetM s a -> SetM s b -> SetM s c #(*>) :: SetM s a -> SetM s b -> SetM s b #(<*) :: SetM s a -> SetM s b -> SetM s a # Source # Instance detailsDefined in CmdLineParser Methodspure :: a -> CmdLineP s a #(<*>) :: CmdLineP s (a -> b) -> CmdLineP s a -> CmdLineP s b #liftA2 :: (a -> b -> c) -> CmdLineP s a -> CmdLineP s b -> CmdLineP s c #(*>) :: CmdLineP s a -> CmdLineP s b -> CmdLineP s b #(<*) :: CmdLineP s a -> CmdLineP s b -> CmdLineP s a # Monad m => Applicative (EwM m) Source # Instance detailsDefined in CmdLineParser Methodspure :: a -> EwM m a #(<*>) :: EwM m (a -> b) -> EwM m a -> EwM m b #liftA2 :: (a -> b -> c) -> EwM m a -> EwM m b -> EwM m c #(*>) :: EwM m a -> EwM m b -> EwM m b #(<*) :: EwM m a -> EwM m b -> EwM m a # Source # Instance detailsDefined in IOEnv Methodspure :: a -> IOEnv m a #(<*>) :: IOEnv m (a -> b) -> IOEnv m a -> IOEnv m b #liftA2 :: (a -> b -> c) -> IOEnv m a -> IOEnv m b -> IOEnv m c #(*>) :: IOEnv m a -> IOEnv m b -> IOEnv m b #(<*) :: IOEnv m a -> IOEnv m b -> IOEnv m a # Applicative m => Applicative (GhcT m) Source # Instance detailsDefined in GhcMonad Methodspure :: a -> GhcT m a #(<*>) :: GhcT m (a -> b) -> GhcT m a -> GhcT m b #liftA2 :: (a -> b -> c) -> GhcT m a -> GhcT m b -> GhcT m c #(*>) :: GhcT m a -> GhcT m b -> GhcT m b #(<*) :: GhcT m a -> GhcT m b -> GhcT m 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 # 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 # 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 # 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 # 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, 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 #(<*>) :: WhenMissing f x (a -> b) -> WhenMissing f x a -> WhenMissing f x b #liftA2 :: (a -> b -> c) -> WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x c #(*>) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x b #(<*) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x a # (Monoid w, Applicative m) => Applicative (WriterT w m) Instance detailsDefined in Control.Monad.Trans.Writer.Lazy Methodspure :: a -> WriterT w m a #(<*>) :: WriterT w m (a -> b) -> WriterT w m a -> WriterT w m b #liftA2 :: (a -> b -> c) -> WriterT w m a -> WriterT w m b -> WriterT w m c #(*>) :: WriterT w m a -> WriterT w m b -> WriterT w m b #(<*) :: WriterT w m a -> WriterT w m b -> WriterT w m a # (Functor m, Monad m) => Applicative (StateT s m) Instance detailsDefined in Control.Monad.Trans.State.Lazy Methodspure :: a -> StateT s m a #(<*>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b #liftA2 :: (a -> b -> c) -> StateT s m a -> StateT s m b -> StateT s m c #(*>) :: StateT s m a -> StateT s m b -> StateT s m b #(<*) :: StateT s m a -> StateT s m b -> StateT s m a # (Functor m, Monad m) => Applicative (ExceptT e m) Instance detailsDefined in Control.Monad.Trans.Except Methodspure :: a -> ExceptT e m a #(<*>) :: ExceptT e m (a -> b) -> ExceptT e m a -> ExceptT e m b #liftA2 :: (a -> b -> c) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c #(*>) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m b #(<*) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m a # 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 # (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 #(<*>) :: WhenMatched f x y (a -> b) -> WhenMatched f x y a -> WhenMatched f x y b #liftA2 :: (a -> b -> c) -> WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y c #(*>) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y b #(<*) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y a # (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 #(<*>) :: WhenMissing f k x (a -> b) -> WhenMissing f k x a -> WhenMissing f k x b #liftA2 :: (a -> b -> c) -> WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x c #(*>) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x b #(<*) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x a # Applicative m => Applicative (ReaderT r m) Instance detailsDefined in Control.Monad.Trans.Reader Methodspure :: a -> ReaderT r m a #(<*>) :: ReaderT r m (a -> b) -> ReaderT r m a -> ReaderT r m b #liftA2 :: (a -> b -> c) -> ReaderT r m a -> ReaderT r m b -> ReaderT r m c #(*>) :: ReaderT r m a -> ReaderT r m b -> ReaderT r m b #(<*) :: ReaderT r m a -> ReaderT r m b -> ReaderT r m 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 # (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 #(<*>) :: WhenMatched f k x y (a -> b) -> WhenMatched f k x y a -> WhenMatched f k x y b #liftA2 :: (a -> b -> c) -> WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y c #(*>) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y b #(<*) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y a # (<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 #

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 #

Monads having fixed points with a 'knot-tying' semantics. Instances of MonadFix should satisfy the following laws:

purity
mfix (return . h) = return (fix h)
left shrinking (or tightening)
mfix (\x -> a >>= \y -> f x y) = a >>= \y -> mfix (\x -> f x y)
sliding
mfix (liftM h . f) = liftM h (mfix (f . h)), for strict h.
nesting
mfix (\x -> mfix (\y -> f x y)) = mfix (\x -> f x x)

This class is used in the translation of the recursive do notation supported by GHC and Hugs.

Methods

mfix :: (a -> m a) -> m a #

The fixed point of a monadic computation. mfix f executes the action f only once, with the eventual output fed back as the input. Hence f should not be strict, for then mfix f would diverge.

Instances

class Monad m => MonadIO (m :: Type -> Type) where #

Monads in which IO computations may be embedded. Any monad built by applying a sequence of monad transformers to the IO monad will be an instance of this class.

Instances should satisfy the following laws, which state that liftIO is a transformer of monads:

• liftIO . return = return
• liftIO (m >>= f) = liftIO m >>= (liftIO . f)

Methods

liftIO :: IO a -> m a #

Lift a computation from the IO monad.

Instances

liftIO1 :: MonadIO m => (a -> IO b) -> a -> m b Source #

Lift an IO operation with 1 argument into another monad

liftIO2 :: MonadIO m => (a -> b -> IO c) -> a -> b -> m c Source #

Lift an IO operation with 2 arguments into another monad

liftIO3 :: MonadIO m => (a -> b -> c -> IO d) -> a -> b -> c -> m d Source #

Lift an IO operation with 3 arguments into another monad

liftIO4 :: MonadIO m => (a -> b -> c -> d -> IO e) -> a -> b -> c -> d -> m e Source #

Lift an IO operation with 4 arguments into another monad

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]) #

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-transforming 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 :: Monad m => (a -> b -> m a) -> a -> [b] -> m a Source #

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

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

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.