[Haskell-cafe] Downsides of the Prompt Monad
Ertugrul Söylemez
esz at posteo.de
Thu Apr 6 16:18:41 UTC 2017
> Could someone outline for me the downsides of using the Prompt monad?
For one thing I find its definition to be overcomplicated for what it
does. For another the same can be achieved with free monads in a more
transparent and flexible manner:
import Control.Monad.Free.Class
data PromptF a b x = PromptF (b -> x) a
deriving (Functor)
prompt :: (MonadFree (PromptF a b) m) => a -> m b
prompt = liftF . PromptF id
Now the kinds of extra effects that you allow depends on which free
monad implementation you use. If you use F, you get the equivalent of
Prompt, if you use FT, you get PromptT. In the F case the iter function
corresponds to runPrompt, iterM corresponds to runPromptM. In the FT
case there are iterT and iterTM.
Greets
ertes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170406/4bb6b616/attachment.sig>
More information about the Haskell-Cafe
mailing list