[Haskell-cafe] Design of a Physics Interface

Bit Connor bit at mutantlemon.com
Fri Nov 30 11:20:12 EST 2007

I think your integrate function looks like a good idea:

> integrate :: TimeStep -> World -> World

For bodies, I think you should have a BodyID type, and then to add a
body to the world you could have a function:

> newBody :: (Position, Velocity) -> World -> (BodyID, World)

To delete a body:

> deleteBody :: BodyID -> World -> World

So your World type will need to contain all of the bodies "inside" it,
something like this:

data World = World { gravity :: Vector, bodies :: [(BodyID, (Position,
Velocity, BodyProperties))]

This is pretty much the way things are done in the FRP paper "The
Yampa Arcade", where they use an "Identity List" where the type ILKey
= Int. See section 5.5 of the paper:


More information about the Haskell-Cafe mailing list