[Haskell-cafe] GHCi and State

Martin Hilbig martin at mhilbig.de
Mon Jun 28 12:19:00 EDT 2010


On 25.06.2010 11:07, corentin.dupont at ext.mpsa.com wrote:
> 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?

check out hint, a nice wrapper around the ghc api [1].

have fun

[1]: http://hackage.haskell.org/package/hint

> 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
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list