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

Ertugrul Söylemez es at ertes.de
Wed Apr 11 21:02:06 CEST 2012

Hi there Nathan,

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

> Ok, I made another attempt. I have a function, to output the state of
> one object:
> objectWire :: StdGen -> MyWire () ObjectState

Minor note:  You do not need to pass random number generators around.
Netwire has native support for noise.  See Control.Wire.Prefab.Random.
A WRandom instance is predefined for IO.  However I just realized a bug.
I forgot to export the WRandom class. =)

Will be fixed in the next release.

> The random generator is used to create the initial state. Now I want
> to handle a dynamic set of objects. This is my attempt:
> [...]
> But I do not understand how to use any of Control.Wire.Trans.Combine
> to handle my dynamic set of wires.

While the context wire transformers allow you to have dynamic wire sets
'distribute' is pretty much static.  In an older release of Netwire
there used to be a 'manager' wire that was specifically designed to
maintain a set of dynamic wires.  I decided to omit it in newer releases
and let library/application authors write a more domain-specific version
of it.  You should be able to just use the old code (perhaps with minor
adjustments to fit the new types), which you can find here:



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/20120411/de5b5eec/attachment.pgp>

More information about the Beginners mailing list