Copyright | (c) Justin Le 2015 |
---|---|
License | MIT |
Maintainer | justin@jle.im |
Stability | unstable |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Provides a typeclass for Applicative
and Monad
types that give you
the ability to, at any time, "prompt" with an a
and get a b
in
response. The power of this instance is that each type gets to define
its own way to deliver a response.
This library provides instances for PromptT
from
Control.Monad.Prompt and the monad transformers in transformers and
mtl. Feel free to create your own instances too.
data Interactive a = Interactive ((String -> String) -> a) -- at any time, ask with a string to get a string instance MonadPrompt String String Interactive where prompt str = Interactive $ f -> f str
- class Applicative m => MonadPrompt a b m | m -> a b where
- prompt' :: MonadPrompt a b m => a -> m b
- prompts' :: MonadPrompt a b m => (b -> c) -> a -> m c
Documentation
class Applicative m => MonadPrompt a b m | m -> a b where Source #
An Applicative
(and possibly Monad
) where you can, at any time,
"prompt" with an a
and receive a b
in response.
Instances include PromptT
and any transformers monad transformer
over another MonadPrompt
.
Prompt with an a
for a b
in the context of the type.
prompts :: (b -> c) -> a -> m c Source #
Prompt with an a
for a b
in the context of the type, and
apply the given function to receive a c
.
(Monad m, MonadPrompt a b m) => MonadPrompt a b (MaybeT m) Source # | |
(Monad m, MonadPrompt a b m, Monoid w) => MonadPrompt a b (WriterT w m) Source # | |
(Monad m, MonadPrompt a b m, Monoid w) => MonadPrompt a b (WriterT w m) Source # | |
(Monad m, MonadPrompt a b m) => MonadPrompt a b (StateT s m) Source # | |
(Monad m, MonadPrompt a b m) => MonadPrompt a b (StateT s m) Source # | |
(Monad m, MonadPrompt a b m) => MonadPrompt a b (ErrorT e m) Source # | |
(Monad m, MonadPrompt a b m) => MonadPrompt a b (ExceptT e m) Source # | |
(Monad m, MonadPrompt a b m) => MonadPrompt a b (ReaderT * r m) Source # | |
Applicative t => MonadPrompt a b (PromptT a b t) Source # | |
(Monad m, MonadPrompt a b m, Monoid w) => MonadPrompt a b (RWST r w s m) Source # | |
(Monad m, MonadPrompt a b m, Monoid w) => MonadPrompt a b (RWST r w s m) Source # | |
prompt' :: MonadPrompt a b m => a -> m b Source #
A version of prompt
strict on its prompting value.
prompts' :: MonadPrompt a b m => (b -> c) -> a -> m c Source #
A version of prompts
strict on its prompting value.