[Haskell-cafe] GHCi and State

Henning Thielemann lemming at henning-thielemann.de
Mon Jun 28 14:38:06 EDT 2010

> On 25.06.2010 11:07, corentin.dupont at ext.mpsa.com wrote:
>> 2. For now, the game is more or less playable in GHCi. But my concern is:
>> When you use GHCi, you are in the IO monad, right? How to had state to this
>> monad?
>> I would like that the player can compose his rule in GHCi, and when he is
>> done, he can submit it in GHCi with something like:
>> *Nomic>  submitRule<myrule>

You can use IORefs for this purpose. However you have to initialize the 
IORef before running the first action and then you must pass the IORef to 
every subsequent action.

More information about the Haskell-Cafe mailing list