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:

http://www.haskell.org/yale/papers/haskell-workshop03/index.html
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to