[Haskell-cafe] question about interruptable state runner
limestrael at gmail.com
Fri Jun 10 15:36:36 CEST 2011
Just for the culture (because Heinrich's solution is undoubtly simpler) you
can also achive this using continuations.
This is one of the purposes of the Cont monad, used jointly with a State
monad, you can store the continuations and resume them later.
2011/6/10 Heinrich Apfelmus <apfelmus at quantentunnel.de>
> Alexander V Vershilov wrote:
>> I'm writing a small tcp server with that can handle connections and
>> answer by rules writen in a small script that can be interpreted by
>> For this purpose I've written an interpreter that has type
>> ErrorT MyError (StateT ScriptState IO)
>> so I can call "native" IO function in that script, and define new one.
>> I can run this script with runState (runErrorT (...)) oldState.
>> But there is one problem: in script i should be able to call functions
>> will stop script interpretation and wait for some server event. To
>> Can smb give an advice what is the best way to do it?
> Basically, you want to stop the interpreter and resume it at some later
> point. You need to implement a custom monad for that, which can easily be
> done with the help of my operational package.
> In particular, the examples
> show how to suspend and resume the control flow. Feel free to request
> additional examples.
> Best regards,
> Heinrich Apfelmus
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe