[Haskell-cafe] Storing functional values
t.zielonka at students.mimuw.edu.pl
Fri Jan 30 17:45:10 EST 2004
On Fri, Jan 30, 2004 at 09:21:58AM -0700, nickgrey at softhome.net wrote:
> 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
> I could obviously, replace all the functional values with non-functional
> ones, and have a big case statement specifying the behaviour associated
> with each constant. However, I don't really like this solution.
Just a vague idea: I think it would be possible to apply some kind of
automatic whole-program transformation that would do most (if not all)
the work for you. The relevant keywords may be "defunctionalisation",
Do you want to be able to save game in one version of the program and
restore it in a newer version? This can be difficult.
.signature: Too many levels of symbolic links
More information about the Haskell-Cafe