
30 Oct
2008
30 Oct
'08
12:07 a.m.
Is there a better way than IORefs
The state Monad.
Do you mean one state shared among all actors, like this? type MGame = State GameState newtype GameState = GameState { <shared state> } That gets part of the way, but I'm thinking of a situation where each instance of a particular type of actor can have its own reference to some other actor: newtype Watcher = Watcher { otherActor :: IORef ActorWrapper } (Here, ActorWrapper is an existential type that hides a specific actor type.) I started writing a game using IORefs that way, allowing actors to see and cause changes in each other, but in the back of my mind I wonder if this is a symptom of a C++ background.