[Haskell-cafe] RE: [Haskell] Making 'Super Nario Bros' in Haskell

Eli Ford eford at griptonite.com
Thu Oct 30 00:07:31 EDT 2008


> > 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.


More information about the Haskell-Cafe mailing list