Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- ifM :: Monad m => m Bool -> m a -> m a -> m a
- unlessM :: Monad m => m Bool -> m () -> m ()
- guardWithError :: MonadError e m => e -> Bool -> m ()
- mapMaybeM :: Monad m => (a -> m (Maybe b)) -> [a] -> m [b]
- tryMaybe :: (MonadError e m, Functor m) => m a -> m (Maybe a)
- bracket_ :: Monad m => m a -> (a -> m ()) -> m b -> m b
- finally :: MonadError e m => m a -> m () -> m a
- tell1 :: (Monoid ws, Singleton w ws, MonadWriter ws m) => w -> m ()
- concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b]
- dropWhileM :: Monad m => (a -> m Bool) -> [a] -> m [a]
- (==<<) :: Monad m => (a -> b -> m c) -> (m a, m b) -> m c
- (<*!>) :: Monad m => m (a -> b) -> m a -> m b
- whenM :: Monad m => m Bool -> m () -> m ()
- guardM :: (Monad m, MonadPlus m) => m Bool -> m ()
- ifNotM :: Monad m => m Bool -> m a -> m a -> m a
- and2M :: Monad m => m Bool -> m Bool -> m Bool
- andM :: (Foldable f, Monad m) => f (m Bool) -> m Bool
- allM :: (Foldable f, Monad m) => f a -> (a -> m Bool) -> m Bool
- or2M :: Monad m => m Bool -> m Bool -> m Bool
- orM :: (Foldable f, Monad m) => f (m Bool) -> m Bool
- anyM :: (Foldable f, Monad m) => f a -> (a -> m Bool) -> m Bool
- altM1 :: Monad m => (a -> m (Either err b)) -> [a] -> m (Either err b)
- orEitherM :: (Monoid e, Monad m, Functor m) => [m (Either e b)] -> m (Either e b)
- mapM' :: (Foldable t, Applicative m, Monoid b) => (a -> m b) -> t a -> m b
- forM' :: (Foldable t, Applicative m, Monoid b) => t a -> (a -> m b) -> m b
- mapMM :: (Traversable t, Monad m) => (a -> m b) -> m (t a) -> m (t b)
- forMM :: (Traversable t, Monad m) => m (t a) -> (a -> m b) -> m (t b)
- mapMM_ :: (Foldable t, Monad m) => (a -> m ()) -> m (t a) -> m ()
- forMM_ :: (Foldable t, Monad m) => m (t a) -> (a -> m ()) -> m ()
- mapMaybeMM :: Monad m => (a -> m (Maybe b)) -> m [a] -> m [b]
- forMaybeM :: Monad m => [a] -> (a -> m (Maybe b)) -> m [b]
- forMaybeMM :: Monad m => m [a] -> (a -> m (Maybe b)) -> m [b]
- dropWhileEndM :: Monad m => (a -> m Bool) -> [a] -> m [a]
- partitionM :: (Functor m, Applicative m) => (a -> m Bool) -> [a] -> m ([a], [a])
- fromMaybeMP :: MonadPlus m => Maybe a -> m a
- catMaybesMP :: MonadPlus m => m (Maybe a) -> m a
- scatterMP :: (MonadPlus m, Foldable t) => m (t a) -> m a
- tryCatch :: (MonadError e m, Functor m) => m () -> m (Maybe e)
- localState :: MonadState s m => m a -> m a
- embedWriter :: forall w (m :: Type -> Type) a. (Monoid w, Monad m) => Writer w a -> WriterT w m a
- when :: Applicative f => Bool -> f () -> f ()
- unless :: Applicative f => Bool -> f () -> f ()
- class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) where
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- (<*>) :: Applicative f => f (a -> b) -> f a -> f b
- (<$!>) :: Monad m => (a -> b) -> m a -> m b
- (<$) :: Functor f => a -> f b -> f a
Documentation
guardWithError :: MonadError e m => e -> Bool -> m () Source #
Like guard
, but raise given error when condition fails.
mapMaybeM :: Monad m => (a -> m (Maybe b)) -> [a] -> m [b] Source #
A monadic version of
.mapMaybe
:: (a -> Maybe b) -> [a] -> [b]
tryMaybe :: (MonadError e m, Functor m) => m a -> m (Maybe a) Source #
Try a computation, return Nothing
if an Error
occurs.
:: Monad m | |
=> m a | Acquires resource. Run first. |
-> (a -> m ()) | Releases resource. Run last. |
-> m b | Computes result. Run in-between. |
-> m b |
Bracket without failure. Typically used to preserve state.
finally :: MonadError e m => m a -> m () -> m a Source #
Finally for the Error
class. Errors in the finally part take
precedence over prior errors.
concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b] Source #
dropWhileM :: Monad m => (a -> m Bool) -> [a] -> m [a] Source #
A monadic version of
.dropWhile
:: (a -> Bool) -> [a] -> [a]
altM1 :: Monad m => (a -> m (Either err b)) -> [a] -> m (Either err b) Source #
Lazy monadic disjunction with Either
truth values.
Returns the last error message if all fail.
orEitherM :: (Monoid e, Monad m, Functor m) => [m (Either e b)] -> m (Either e b) Source #
Lazy monadic disjunction with accumulation of errors in a monoid. Errors are discarded if we succeed.
mapM' :: (Foldable t, Applicative m, Monoid b) => (a -> m b) -> t a -> m b Source #
Generalized version of traverse_ :: Applicative m => (a -> m ()) -> [a] -> m ()
Executes effects and collects results in left-to-right order.
Works best with left-associative monoids.
Note that there is an alternative
mapM' f t = foldr mappend mempty $ mapM f t
that collects results in right-to-left order (effects still left-to-right). It might be preferable for right associative monoids.
forM' :: (Foldable t, Applicative m, Monoid b) => t a -> (a -> m b) -> m b Source #
Generalized version of for_ :: Applicative m => [a] -> (a -> m ()) -> m ()
mapMaybeMM :: Monad m => (a -> m (Maybe b)) -> m [a] -> m [b] Source #
A version of
with a computation for the input list.mapMaybeM
forMaybeMM :: Monad m => m [a] -> (a -> m (Maybe b)) -> m [b] Source #
The for
version of mapMaybeMM
.
dropWhileEndM :: Monad m => (a -> m Bool) -> [a] -> m [a] Source #
A monadic version of
.
Effects happen starting at the end of the list until dropWhileEnd
:: (a -> Bool) -> [a] -> m [a]p
becomes false.
partitionM :: (Functor m, Applicative m) => (a -> m Bool) -> [a] -> m ([a], [a]) Source #
A `monadic'
version of @partition
:: (a -> Bool) -> [a] -> ([a],[a])
catMaybesMP :: MonadPlus m => m (Maybe a) -> m a Source #
scatterMP :: (MonadPlus m, Foldable t) => m (t a) -> m a Source #
Branch over elements of a monadic Foldable
data structure.
tryCatch :: (MonadError e m, Functor m) => m () -> m (Maybe e) Source #
Run a command, catch the exception and return it.
localState :: MonadState s m => m a -> m a Source #
Restore state after computation.
embedWriter :: forall w (m :: Type -> Type) a. (Monoid w, Monad m) => Writer w a -> WriterT w m a Source #
class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) where #
Nothing