[Haskell-cafe] GHCi and State
corentin.dupont at ext.mpsa.com
corentin.dupont at ext.mpsa.com
Fri Jun 25 05:07:49 EDT 2010
Another couple of reflexions (sorry for monopolizing):
1. Since i am making a Nomic game, players will have to submit rules. These
rules will be written in a sub-set of haskell.
Instead of writing my own reader/interpreter, i'd like to use GHC to compil
them on the fly, and then add them to the current "legislation".
What would you suggest me to do that? Any pointers?
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>
And then the game takes the rule, possibly modify the current legislation,
and give the hand back to GHCi.
So the "current legislation" has to be a state of the GHCi's loop. Is this
possible at all?
submitRule would have a type more or less like that (GameState contains the
legislation):
submitRule :: Rule -> StateT GameState IO ()
Thanks for your attention! I know this is a bit confused!
Best,
Corentin
More information about the Haskell-Cafe
mailing list