[Haskell-beginners] dynamic set of objects in netwire

Ertugrul Söylemez es at ertes.de
Fri Nov 9 04:06:54 CET 2012

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

> >> The most obvious interface is through input.  However, this really
> >> only works when only the user of the manager should be able to add
> >> or remove subwires.  The interface is as simple as something like
> >> this:
> >>
> >>     data MgrMsg k e m a b =
> >>         Add k (Wire e m a b) |
> >>         Delete k
> >>
> >>     managerBasic ::
> >>         (Monad m, Monoid b, Ord k) =>
> >>         Wire e m (a, [MgrMsg k e m a b]) b
> >
> > Mmh, how could you (form the outside) connect the output to the
> > induvidual managed wires?
> > Let's say I from one of the values in the output "b" I decide I want
> > to delete the corresponding wire? I need to know the key "k".  OK, I
> > could encode "k" in the output but should I then not explicitly
> > return "k" with it?
> Acually I am just realizing that I can "plumb" my wires so, that its
> output is (k,b) to get exactly this effect.

This is a more general problem:  How does a subwire /select/ a key for a
new wire it wants to create?  To most obvious answer is to use the
underlying monad, which should be safe enough.  Otherwise you can allow
adding without a key and the corresponding subwire then gets the key fed


Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- 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/20121109/65374ff9/attachment.pgp>

More information about the Beginners mailing list