[Haskell-beginners] FRP and a set of pairwise interacting (colliding) objects

Ertugrul Söylemez es at ertes.de
Fri Jun 29 16:47:44 CEST 2012


Nathan Hüsken <nathan.huesken at posteo.de> wrote:

> [...]
>
> But now the collisions are generated at one place, and processed at
> another. This means that CollData must be somehow tagged to the
> objects it belongs to (an ID for example). This again means that some
> function must take the pool of all collision datas and distribute them
> to the "object" Signals.
>
> When I have a lot of objects, this means a significant overhead!
>
> Now I am wondering if there is a nicer approach which avoids this
> overhead.

You can get around the overhead by letting the objects do the collisions
themselves, much like in your OOP variant.  For instance in Netwire you
could have this:

    planets :: MyWire [Planet] Planet

This naive way still causes the overhead of lists and a planet
distinguishing between others and itself.  But now this is simply a
matter of choosing proper data structures and starting to identify
planets:

    type PlanetSet = Map PlanetId Planet

    planets :: MyWire PlanetSet (PlanetId, Planet)

This looks more promising.  Now the last thing is that this looks like a
chicken/egg problem, but it's easy to resolve using ArrowLoop and
one-instant delays.


Greets,
Ertugrul

-- 
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120629/af3e6653/attachment.pgp>


More information about the Beginners mailing list