[Haskell-beginners] Trying to write netwire combiner similar to multicast

Nathan Hüsken nathan.huesken at posteo.de
Tue Nov 6 13:24:42 CET 2012


On 11/06/2012 02:44 AM, Ertugrul Söylemez wrote:
> Nathan Hüsken <nathan.huesken at posteo.de> wrote:
> 
>>> Also your interface seems very unsafe to me.  I suggest the
>>> following interface instead:
>>>
>>>     shrinking :: (Monad m) => [Wire e m a b] -> Wire e m a [b]
>>>
>>> Then normally 'a' could be something like Map K A.
>>
>> That would mean, the individual wires have to know there own id?!?
>> Mmmh, I will try to keep this bookkeeping out of the wires with this
>> interface:
>>
>> shrinking :: (Monad m) => [Wire e m a b] -> Wire e m (Map Int a)
>> (Int,b)
>>
>> shrinking will assign the ids to the wires and returns them with the
>> result. I will see where this gets me ... :).
> 
> The problem with such an interface is the inflexibility.  Notice that
> removing a subwire will change the numbering of all subsequent wires.
> The interface I suggested follows this basic idea:
> 
>     shrinking ::
>         (Monad m)
>         => [(a' -> a, Wire e m a b)]
>         -> Wire e m a' b
> 

That should be ".. -> Wire e m a' [b]", correct?

> The reasoning is that this way you disconnect the individual values from
> the positions in the subwire list.  This will also make writing the
> combinator a bit simpler.  If you will here is an interesting
> alternative:
> 
>     data Subwire e m a b =
>         forall a'. Subwire (a -> a') (Wire e m a' b)
> 
>     shrinking :: (Monad m) => [Subwire e m a b] -> Wire e m a b
> 

Ohh, the scary forall keyword :).
Here it does nothing but hide the a' type from the type signature, is
that correct?

Thanks!
Nathan





More information about the Beginners mailing list