[Haskell-beginners] Using Traversal as a kind of pointer

Elise Huard haskell at elisehuard.be
Mon Aug 18 11:09:11 UTC 2014


Hi,

I'm programming a small game - amongst my types I have a 'world' structure
data World = World Background [Lifeform]
I'm calculating collisions between my player and the lifeforms, and
I'll need this result both to allow some actions and to modify the
world as a result.
I'm using FRP with elerea, so everything is defined as behaviours
(signals), and the collision signal is used in the signal accounting
of life spent and in the world signal.
I was thinking of returning a Traversal on the lifeforms that are
colliding so that I can both access the lifeforms concerned (when
performing actions and life accounting) and modify them as a result
(for the world).
Does that sound reasonable as a use of lenses?  Overengineered? Better
solutions?
Thank you,

Elise Huard


More information about the Beginners mailing list