[Haskell-cafe] Interpreter with Cont

Felipe Almeida Lessa felipe.lessa at gmail.com
Sat Nov 19 21:29:35 CET 2011


On Sat, Nov 19, 2011 at 6:08 PM, Tim Baumgartner
<baumgartner.tim at googlemail.com> wrote:
> I have not yet gained a good understanding of the continuation monad, but I
> wonder if it could be used here. What would a clean solution look like?
> Perhaps there are other things that need to be changed as well?

Your 'Interaction' data type is actually an instance of the more
general "operational monad" (as named by Heinrich Apfelmus) or "prompt
monad" (as named by Ryan Ingram).  You will ready-to-use
implementations on the packages MonadPrompt [1] and operational [2,3].
 Reading their documentation you'll find some links about the
development of these concepts.  MonadPrompt uses a Cont-style
implementation, while operational uses a simple abstract data type
together with a viewing function that avoids O(n²) behavior.

If you find it hard to describe your 'Interaction' using operational
(easiest to use package, IMO), please send us another e-mail.

Cheers!

[1] http://hackage.haskell.org/package/MonadPrompt
[2] http://hackage.haskell.org/package/operational
[3] http://heinrichapfelmus.github.com/operational/Documentation.html

-- 
Felipe.



More information about the Haskell-Cafe mailing list