| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
MonadUtils
Description
Utilities related to Monad and Applicative classes Mostly for backwards compatibility.
Synopsis
- class Functor f => Applicative (f :: Type -> Type) where
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- class Monad m => MonadFix (m :: Type -> Type) where
- mfix :: (a -> m a) -> m a
- class Monad m => MonadIO (m :: Type -> Type) where
- liftIO1 :: MonadIO m => (a -> IO b) -> a -> m b
- liftIO2 :: MonadIO m => (a -> b -> IO c) -> a -> b -> m c
- liftIO3 :: MonadIO m => (a -> b -> c -> IO d) -> a -> b -> c -> m d
- liftIO4 :: MonadIO m => (a -> b -> c -> d -> IO e) -> a -> b -> c -> d -> m e
- zipWith3M :: Monad m => (a -> b -> c -> m d) -> [a] -> [b] -> [c] -> m [d]
- zipWith3M_ :: Monad m => (a -> b -> c -> m d) -> [a] -> [b] -> [c] -> m ()
- zipWith4M :: Monad m => (a -> b -> c -> d -> m e) -> [a] -> [b] -> [c] -> [d] -> m [e]
- zipWithAndUnzipM :: Monad m => (a -> b -> m (c, d)) -> [a] -> [b] -> m ([c], [d])
- mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c])
- mapAndUnzip3M :: Monad m => (a -> m (b, c, d)) -> [a] -> m ([b], [c], [d])
- mapAndUnzip4M :: Monad m => (a -> m (b, c, d, e)) -> [a] -> m ([b], [c], [d], [e])
- mapAndUnzip5M :: Monad m => (a -> m (b, c, d, e, f)) -> [a] -> m ([b], [c], [d], [e], [f])
- mapAccumLM :: Monad m => (acc -> x -> m (acc, y)) -> acc -> [x] -> m (acc, [y])
- mapSndM :: Monad m => (b -> m c) -> [(a, b)] -> m [(a, c)]
- concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b]
- mapMaybeM :: Monad m => (a -> m (Maybe b)) -> [a] -> m [b]
- fmapMaybeM :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b)
- fmapEitherM :: Monad m => (a -> m b) -> (c -> m d) -> Either a c -> m (Either b d)
- anyM :: Monad m => (a -> m Bool) -> [a] -> m Bool
- allM :: Monad m => (a -> m Bool) -> [a] -> m Bool
- orM :: Monad m => m Bool -> m Bool -> m Bool
- foldlM :: Monad m => (a -> b -> m a) -> a -> [b] -> m a
- foldlM_ :: Monad m => (a -> b -> m a) -> a -> [b] -> m ()
- foldrM :: Monad m => (b -> a -> m a) -> a -> [b] -> m a
- maybeMapM :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b)
- whenM :: Monad m => m Bool -> m () -> m ()
- unlessM :: Monad m => m Bool -> m () -> m ()
Documentation
class Functor f => Applicative (f :: Type -> Type) where Source #
A functor with application, providing operations to
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:
(<*>) =liftA2id
liftA2f x y = f<$>x<*>y
Further, any definition must satisfy the following:
- identity
pureid<*>v = v- composition
pure(.)<*>u<*>v<*>w = u<*>(v<*>w)- homomorphism
puref<*>purex =pure(f x)- interchange
u
<*>purey =pure($y)<*>u
The other methods have the following default definitions, which may be overridden with equivalent specialized implementations:
As a consequence of these laws, the Functor instance for f will satisfy
It may be useful to note that supposing
forall x y. p (q x y) = f x . g y
it follows from the above that
liftA2p (liftA2q u v) =liftA2f u .liftA2g v
If f is also a Monad, it should satisfy
(which implies that pure and <*> satisfy the applicative functor laws).
Methods
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.
(*>) :: f a -> f b -> f b infixl 4 Source #
Sequence actions, discarding the value of the first argument.
(<*) :: f a -> f b -> f a infixl 4 Source #
Sequence actions, discarding the value of the second argument.
Instances
| Applicative [] | Since: base-2.1 |
| Applicative Maybe | Since: base-2.1 |
| Applicative IO | Since: base-2.1 |
| Applicative Par1 | Since: base-4.9.0.0 |
| Applicative Q | |
| Applicative Complex | Since: base-4.9.0.0 |
| Applicative Min | Since: base-4.9.0.0 |
| Applicative Max | Since: base-4.9.0.0 |
| Applicative First | Since: base-4.9.0.0 |
| Applicative Last | Since: base-4.9.0.0 |
| Applicative Option | Since: base-4.9.0.0 |
| Applicative ZipList | f '<$>' 'ZipList' xs1 '<*>' ... '<*>' 'ZipList' xsN
= 'ZipList' (zipWithN f xs1 ... xsN)where (\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 |
Defined in Control.Applicative | |
| Applicative Identity | Since: base-4.8.0.0 |
Defined in Data.Functor.Identity | |
| Applicative STM | Since: base-4.8.0.0 |
| Applicative First | Since: base-4.8.0.0 |
| Applicative Last | Since: base-4.8.0.0 |
| Applicative Dual | Since: base-4.8.0.0 |
| Applicative Sum | Since: base-4.8.0.0 |
| Applicative Product | Since: base-4.8.0.0 |
Defined in Data.Semigroup.Internal | |
| Applicative Down | Since: base-4.11.0.0 |
| Applicative ReadPrec | Since: base-4.6.0.0 |
Defined in Text.ParserCombinators.ReadPrec | |
| Applicative ReadP | Since: base-4.6.0.0 |
| Applicative NonEmpty | Since: base-4.9.0.0 |
Defined in GHC.Base | |
| Applicative PutM | |
| Applicative Get | |
| Applicative Put | |
| Applicative Tree | |
| Applicative Seq | Since: containers-0.5.4 |
| Applicative Capability | |
Defined in System.Console.Terminfo.Base Methods pure :: 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 # | |
| Applicative P | Since: base-4.5.0.0 |
| Applicative Pair # | |
| Applicative UniqSM # | |
| Applicative CoreM # | |
| Applicative P # | |
| Applicative PD # | |
| Applicative UnifyResultM # | |
Defined in Unify Methods pure :: a -> UnifyResultM a Source # (<*>) :: UnifyResultM (a -> b) -> UnifyResultM a -> UnifyResultM b Source # liftA2 :: (a -> b -> c) -> UnifyResultM a -> UnifyResultM b -> UnifyResultM c Source # (*>) :: UnifyResultM a -> UnifyResultM b -> UnifyResultM b Source # (<*) :: UnifyResultM a -> UnifyResultM b -> UnifyResultM a Source # | |
| Applicative LlvmM # | |
| Applicative FCode # | |
| Applicative CmmParse # | |
Defined in StgCmmExtCode | |
| Applicative Hsc # | |
| Applicative TcPluginM # | |
Defined in TcRnTypes | |
| Applicative CompPipeline # | |
Defined in PipelineMonad Methods pure :: a -> CompPipeline a Source # (<*>) :: CompPipeline (a -> b) -> CompPipeline a -> CompPipeline b Source # liftA2 :: (a -> b -> c) -> CompPipeline a -> CompPipeline b -> CompPipeline c Source # (*>) :: CompPipeline a -> CompPipeline b -> CompPipeline b Source # (<*) :: CompPipeline a -> CompPipeline b -> CompPipeline a Source # | |
| Applicative Ghc # | |
| Applicative SimplM # | |
| Applicative CpsRn # | |
| Applicative OccCheckResult # | |
Defined in TcUnify Methods pure :: a -> OccCheckResult a Source # (<*>) :: OccCheckResult (a -> b) -> OccCheckResult a -> OccCheckResult b Source # liftA2 :: (a -> b -> c) -> OccCheckResult a -> OccCheckResult b -> OccCheckResult c Source # (*>) :: OccCheckResult a -> OccCheckResult b -> OccCheckResult b Source # (<*) :: OccCheckResult a -> OccCheckResult b -> OccCheckResult a Source # | |
| Applicative TcS # | |
| Applicative NatM # | |
| Applicative (Either e) | Since: base-3.0 |
Defined in Data.Either | |
| Applicative (U1 :: Type -> Type) | Since: base-4.9.0.0 |
| Monoid a => Applicative ((,) a) | For tuples, the ("hello ", (+15)) <*> ("world!", 2002)
("hello world!",2017)Since: base-2.1 |
| Applicative (ST s) | Since: base-4.4.0.0 |
| Monad m => Applicative (WrappedMonad m) | Since: base-2.1 |
Defined in Control.Applicative Methods pure :: 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 |
Defined in Control.Arrow Methods pure :: 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 # | |
| Applicative (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
| (Functor m, Monad m) => Applicative (MaybeT m) | |
Defined in Control.Monad.Trans.Maybe | |
| Applicative (ListT f) # | |
| Applicative (State s) # | |
| Applicative (MaybeErr err) # | |
Defined in Maybes Methods pure :: 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 # | |
| Applicative (SetM s) | |
| Applicative (CmdLineP s) # | |
Defined in CmdLineParser Methods pure :: 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) # | |
| Applicative (IOEnv m) # | |
| Applicative (RegM freeRegs) # | |
Defined in RegAlloc.Linear.State Methods pure :: 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 # | |
| Applicative m => Applicative (GhcT m) # | |
| Applicative f => Applicative (Rec1 f) | Since: base-4.9.0.0 |
| Arrow a => Applicative (WrappedArrow a b) | Since: base-2.1 |
Defined in Control.Applicative Methods pure :: 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 # | |
| Monoid m => Applicative (Const m :: Type -> Type) | Since: base-2.0.1 |
Defined in Data.Functor.Const | |
| Applicative f => Applicative (Ap f) | Since: base-4.12.0.0 |
| Applicative f => Applicative (Alt f) | Since: base-4.8.0.0 |
| (Applicative f, Monad f) => Applicative (WhenMissing f x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal Methods pure :: 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 # | |
| (Monoid w, Applicative m) => Applicative (WriterT w m) | |
Defined in Control.Monad.Trans.Writer.Lazy Methods pure :: 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 # | |
| (Functor m, Monad m) => Applicative (StateT s m) | |
Defined in Control.Monad.Trans.State.Strict Methods pure :: 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) | |
Defined in Control.Monad.Trans.State.Lazy Methods pure :: 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 # | |
| Applicative m => Applicative (ReaderT r m) | |
Defined in Control.Monad.Trans.Reader Methods pure :: 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 (ExceptT e m) | |
Defined in Control.Monad.Trans.Except Methods pure :: 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 # | |
| Monad m => Applicative (Stream m a) # | |
Defined in Stream Methods pure :: 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 # | |
| Applicative ((->) a :: Type -> Type) | Since: base-2.1 |
| Monoid c => Applicative (K1 i c :: Type -> Type) | Since: base-4.12.0.0 |
| (Applicative f, Applicative g) => Applicative (f :*: g) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| (Applicative f, Applicative g) => Applicative (Product f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product Methods pure :: 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 # | |
| (Monad f, Applicative f) => Applicative (WhenMatched f x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal Methods pure :: 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 Since: containers-0.5.9 |
Defined in Data.Map.Internal Methods pure :: 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 f => Applicative (M1 i c f) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| (Applicative f, Applicative g) => Applicative (f :.: g) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| (Applicative f, Applicative g) => Applicative (Compose f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose Methods pure :: 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 # | |
| (Monad f, Applicative f) => Applicative (WhenMatched f k x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal Methods pure :: 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 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
Convert from a to a Maybe Int using Maybe Stringshow:
>>>show <$> NothingNothing>>>show <$> Just 3Just "3"
Convert from an to an Either Int IntEither IntString using show:
>>>show <$> Left 17Left 17>>>show <$> Right 17Right "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(fixh)- left shrinking (or tightening)
mfix(\x -> a >>= \y -> f x y) = a >>= \y ->mfix(\x -> f x y)- sliding
, for strictmfix(liftMh . f) =liftMh (mfix(f . h))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
Instances
| MonadFix [] | Since: base-2.1 |
Defined in Control.Monad.Fix | |
| MonadFix Maybe | Since: base-2.1 |
| MonadFix IO | Since: base-2.1 |
| MonadFix Par1 | Since: base-4.9.0.0 |
| MonadFix Min | Since: base-4.9.0.0 |
| MonadFix Max | Since: base-4.9.0.0 |
| MonadFix First | Since: base-4.9.0.0 |
| MonadFix Last | Since: base-4.9.0.0 |
| MonadFix Option | Since: base-4.9.0.0 |
| MonadFix Identity | Since: base-4.8.0.0 |
| MonadFix First | Since: base-4.8.0.0 |
| MonadFix Last | Since: base-4.8.0.0 |
| MonadFix Dual | Since: base-4.8.0.0 |
| MonadFix Sum | Since: base-4.8.0.0 |
| MonadFix Product | Since: base-4.8.0.0 |
| MonadFix Down | Since: base-4.12.0.0 |
| MonadFix NonEmpty | Since: base-4.9.0.0 |
| MonadFix Tree | Since: containers-0.5.11 |
| MonadFix Seq | Since: containers-0.5.11 |
| MonadFix UniqSM # | |
| MonadFix Ghc # | |
| MonadFix (Either e) | Since: base-4.3.0.0 |
| MonadFix (ST s) | Since: base-2.1 |
| MonadFix m => MonadFix (MaybeT m) | |
| MonadFix f => MonadFix (Rec1 f) | Since: base-4.9.0.0 |
| MonadFix f => MonadFix (Ap f) | Since: base-4.12.0.0 |
| MonadFix f => MonadFix (Alt f) | Since: base-4.8.0.0 |
| (Monoid w, MonadFix m) => MonadFix (WriterT w m) | |
| MonadFix m => MonadFix (StateT s m) | |
| MonadFix m => MonadFix (StateT s m) | |
| MonadFix m => MonadFix (ReaderT r m) | |
| MonadFix m => MonadFix (ExceptT e m) | |
| MonadFix ((->) r :: Type -> Type) | Since: base-2.1 |
Defined in Control.Monad.Fix | |
| (MonadFix f, MonadFix g) => MonadFix (f :*: g) | Since: base-4.9.0.0 |
| (MonadFix f, MonadFix g) => MonadFix (Product f g) | Since: base-4.9.0.0 |
| MonadFix f => MonadFix (M1 i c f) | Since: base-4.9.0.0 |
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:
Instances
| MonadIO IO | Since: base-4.9.0.0 |
| MonadIO Q | |
| MonadIO CoreM # | |
| MonadIO Hsc # | |
| MonadIO CompPipeline # | |
Defined in PipelineMonad Methods liftIO :: IO a -> CompPipeline a Source # | |
| MonadIO Ghc # | |
| MonadIO SimplM # | |
| MonadIO m => MonadIO (MaybeT m) | |
| MonadIO (IOEnv env) # | |
| MonadIO m => MonadIO (GhcT m) # | |
| (Monoid w, MonadIO m) => MonadIO (WriterT w m) | |
| MonadIO m => MonadIO (StateT s m) | |
| MonadIO m => MonadIO (StateT s m) | |
| MonadIO m => MonadIO (ReaderT r m) | |
| MonadIO m => MonadIO (ExceptT e m) | |
liftIO1 :: MonadIO m => (a -> IO b) -> a -> m b #
Lift an IO operation with 1 argument into another monad
liftIO2 :: MonadIO m => (a -> b -> IO c) -> a -> b -> m c #
Lift an IO operation with 2 arguments into another monad
liftIO3 :: MonadIO m => (a -> b -> c -> IO d) -> a -> b -> c -> m d #
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 #
Lift an IO operation with 4 arguments into another monad
zipWith3M_ :: Monad m => (a -> b -> c -> m d) -> [a] -> [b] -> [c] -> m () #
zipWithAndUnzipM :: Monad m => (a -> b -> m (c, d)) -> [a] -> [b] -> m ([c], [d]) #
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-transforming monad.
mapAndUnzip3M :: Monad m => (a -> m (b, c, d)) -> [a] -> m ([b], [c], [d]) #
mapAndUnzipM for triples
mapAndUnzip4M :: Monad m => (a -> m (b, c, d, e)) -> [a] -> m ([b], [c], [d], [e]) #
mapAndUnzip5M :: Monad m => (a -> m (b, c, d, e, f)) -> [a] -> m ([b], [c], [d], [e], [f]) #
Arguments
| :: Monad m | |
| => (acc -> x -> m (acc, y)) | combining function |
| -> acc | initial state |
| -> [x] | inputs |
| -> m (acc, [y]) | final state, outputs |
Monadic version of mapAccumL
concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b] #
Monadic version of concatMap
fmapMaybeM :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b) #
Monadic version of fmap
fmapEitherM :: Monad m => (a -> m b) -> (c -> m d) -> Either a c -> m (Either b d) #
Monadic version of fmap
anyM :: Monad m => (a -> m Bool) -> [a] -> m Bool #
Monadic version of any, aborts the computation at the first True value
allM :: Monad m => (a -> m Bool) -> [a] -> m Bool #
Monad version of all, aborts the computation at the first False value
foldlM_ :: Monad m => (a -> b -> m a) -> a -> [b] -> m () #
Monadic version of foldl that discards its result
maybeMapM :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b) #
Monadic version of fmap specialised for Maybe