[Haskell-beginners] Trying to write netwire combiner similar to multicast
Ertugrul Söylemez
es at ertes.de
Mon Nov 5 17:29:49 CET 2012
Nathan Hüsken <nathan.huesken at posteo.de> wrote:
> I am trying to write a netwire combiner similar to multicast. The only
> difference is that when one of the wires inihibts, I want to remove it
> from the list.
>
> So this is my attempt:
>
> manager :: (Monad m) => [Wire e m a b] -> Wire e m [a] [b]
> manager ws' = mkGen $ \dt xs' -> do
> res <- mapM (\(w,x) -> stepWire w dt x) $ zip ws' xs'
> let filt (Left a, b) = Just (a, b)
> filt _ = Nothing
> resx = mapMaybe filt res
> return (Left $ (fmap fst) resx,manager (fmap snd resx))
Notice that Left means inhibition. You seem to be filtering out
produced results and trying to keep only the inhibition values, which of
course does not make much sense and triggers the type error you are
seeing.
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.
Greets,
Ertugrul
--
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/20121105/35a4df3f/attachment.pgp>
More information about the Beginners
mailing list