Agda-2.2.10: A dependently typed functional programming language and proof assistant

Agda.Utils.Monad

Synopsis

- (<.>) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
- whenM :: Monad m => m Bool -> m () -> m ()
- unlessM :: Monad m => m Bool -> m () -> m ()
- ifM :: Monad m => m Bool -> m a -> m a -> m a
- forgetM :: Applicative m => m a -> m ()
- concatMapM :: Applicative m => (a -> m [b]) -> [a] -> m [b]
- forceM :: Monad m => [a] -> m ()
- commuteM :: (Traversable f, Applicative m) => f (m a) -> m (f a)
- fmapM :: (Traversable f, Applicative m) => (a -> m b) -> f a -> m (f b)
- type Cont r a = (a -> r) -> r
- thread :: (a -> Cont r b) -> [a] -> Cont r [b]
- zipWithM' :: Monad m => (a -> b -> m c) -> [a] -> [b] -> m [c]
- finally :: (Error e, MonadError e m) => m a -> m b -> m a
- bracket :: (Error e, MonadError e m) => m a -> (a -> m c) -> (a -> m b) -> m b
- mapMaybeM :: Applicative m => (a -> m b) -> Maybe a -> m (Maybe b)
- liftEither :: MonadError e m => Either e a -> m a
- readM :: (Error e, MonadError e m, Read a) => String -> m a
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- (<*>) :: Applicative f => forall a b. f (a -> b) -> f a -> f b

# Documentation

(<.>) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c

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

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

ifM :: Monad m => m Bool -> m a -> m a -> m a

forgetM :: Applicative m => m a -> m ()

concatMapM :: Applicative m => (a -> m [b]) -> [a] -> m [b]

forceM :: Monad m => [a] -> m ()

Depending on the monad you have to look at the result for the force to be effective. For the `IO` monad you do.

commuteM :: (Traversable f, Applicative m) => f (m a) -> m (f a)

fmapM :: (Traversable f, Applicative m) => (a -> m b) -> f a -> m (f b)

type Cont r a = (a -> r) -> r

thread :: (a -> Cont r b) -> [a] -> Cont r [b]

`mapM` for the continuation monad. Terribly useful.

zipWithM' :: Monad m => (a -> b -> m c) -> [a] -> [b] -> m [c]

Requires both lists to have the same lengths.

finally :: (Error e, MonadError e m) => m a -> m b -> m a

Finally for the `Error` class. Errors in the finally part take precedence over prior errors.

bracket

Arguments

:: (Error e, MonadError e m) |
=> m a | Acquires resource. Run first.
-> (a -> m c) | Releases resource. Run last.
-> (a -> m b) | Computes result. Run in-between.
-> m b |

Bracket for the `Error` class.

mapMaybeM :: Applicative m => (a -> m b) -> Maybe a -> m (Maybe b)

liftEither :: MonadError e m => Either e a -> m a

readM :: (Error e, MonadError e m, Read a) => String -> m a

(<$>) :: Functor f => (a -> b) -> f a -> f b

An infix synonym for `fmap`.

(<*>) :: Applicative f => forall a b. f (a -> b) -> f a -> f b

Sequential application.