[Haskell-cafe] Help mixing pure and IO code
Felipe Lessa
felipe.lessa at gmail.com
Sun Nov 29 11:07:33 EST 2009
On Sun, Nov 29, 2009 at 03:11:23PM +0100, papa.eric at free.fr wrote:
> However, I wonder how to do it reusing the "pure" versions,
> runGame and Strategy?
There's a nice approach to this problem which is described and
implemented in the MonadPrompt package[1]. Basically you have
prompt :: MonadPrompt p m => p a -> m a
which allows you to interact with the outside world. The beauty
here is that the interection is generic, you may write a pure
simulator (like yours), an IO-heavy game (like what you're
trying) and possibly more, like unit tests and property checks.
Cheers,
[1] http://hackage.haskell.org/package/MonadPrompt
--
Felipe.
More information about the Haskell-Cafe
mailing list