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

Nathan Hüsken nathan.huesken at posteo.de
Mon Nov 5 17:04:51 CET 2012


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))

ghc gives this compiler error:

    Couldn't match type `e' with `[e]'
      `e' is a rigid type variable bound by
          the type signature for
            manager :: Monad m => [Wire e m a b] -> Wire e m [a] [b]
          at BreakoutImproved.hs:85:1
    Expected type: [(e, Wire [e] m a b)]
      Actual type: [(e, Wire e m a b)]
    In the second argument of `fmap', namely `resx'
    In the first argument of `manager', namely `(fmap snd resx)'

Now this, I do not get.
Why does manager expect an argument of type [(e, Wire [e] m a b)].
The type signature clearly says [(e, Wire e m a b)] (which is what it is


More information about the Beginners mailing list