
On Fri, Jan 30, 2004 at 09:21:58AM -0700, nickgrey@softhome.net wrote:
Hi,
I'm writing a game in Haskell. The game state includes a lot of closures. For example, if a game object wants to trigger an event at a particular time, it adds a function (WorldState -> WorldState) to a queue. Similarly there are queues which contain lists of functions which respond to events. (CreatureAttackEvent -> WorldState -> WorldState)
I'd like to be able to save the game state to disk so that it can be reloaded. Obviously, these closures are now a problem, as they can't be stored.
It seems like there are two things you want to do with these functional closures: save them to disk, and run them as functions. Why not combine these two into a type class? Peace, Dylan