[Haskell-beginners] netwire and "dynamic" list of objects

Ertugrul Söylemez es at ertes.de
Tue Apr 10 13:57:02 CEST 2012

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

> I have a simple SDL based graphic demo, which I am trying (for
> educational purposes) to rewrite utilizing netwire.
> The demo basically consists of a State which contains a list of object
> states.
> [...]
> But I avoided rewriting "updateState" in wire format. But I have no
> Idea how to do that.
> How do I handle a dynamic list of objects in a wire?

Well, you are not really using FRP here.  You are just forcing this
application into the FRP model.  Your only behavior is the application
itself.  This works, but buys you nothing.

The first step to actually making use of FRP here is to get rid of the
concept of "updating" something.  Express your game objects themselves
as wires:

    player :: GameWire (Input, [Wall]) Player
    wall   :: GameWire a Wall
    enemy  :: GameWire (Player, [Wall]) Enemy

This allows you to write static game worlds.  After that you can move to
dynamic game worlds using wire transformers from
Control.Wire.Trans.Combine.  It is also pretty straightforward to write
your own wire transformers for this purpose.  You probably want to do
that later -- just look at the source code.


nightmare = unsafePerformIO (getWrongWife >>= sex)
-------------- 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/20120410/ba34745b/attachment.pgp>

More information about the Beginners mailing list