Control.Monad.Util
Description
Extra monad functions and instances
- class (MonadIO m, Applicative m, Functor m) => MonadIO' m
- loop :: (Functor m, Monad m) => m (Maybe a) -> m [a]
- untilJust :: Monad m => (a -> m (Maybe b)) -> [a] -> m (Maybe b)
- untilSuccess :: (MonadError e m, Error e) => (a -> m b) -> [a] -> m b
- untilSuccess' :: MonadError e m => e -> (a -> m b) -> [a] -> m b
- mapError :: Functor m => (e' -> e) -> ErrorT e' m a -> ErrorT e m a
- whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
Documentation
class (MonadIO m, Applicative m, Functor m) => MonadIO' m Source
MonadIO with extra Applicative and Functor superclasses
Instances
(MonadIO m, Applicative m, Functor m) => MonadIO' m |
loop :: (Functor m, Monad m) => m (Maybe a) -> m [a]Source
Repeatedy execute action, collecting results, until it returns Nothing
untilJust :: Monad m => (a -> m (Maybe b)) -> [a] -> m (Maybe b)Source
Apply action to elements one at a time until one returns Just. Return Nothing if all return Nothing.
untilSuccess :: (MonadError e m, Error e) => (a -> m b) -> [a] -> m bSource
Apply action to elements one at a time until one succeeds. Throw last error if all fail. Throw strMsg
error if list is empty.
untilSuccess' :: MonadError e m => e -> (a -> m b) -> [a] -> m bSource
Apply action to elements one at a time until one succeeds. Throw last error if all fail. Throw given error if list is empty