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

Reply via email to