p1 `idealOp` p2 What's the type signature you're shooting for with `idealOp`?
The idea of what you're doing looks sane to me. To put a few names to it: dup :: a ~> (a,a) dup = arr $ \a -> (a,a) decouple :: (a,b) ~> Either a b decouple = forever $ await >>= \(a,b) -> yield (Left a) >> yield (Right b) (&&&) :: (a ~> b) -> (a ~> c) -> (a ~> (b,c)) -- ^ for comparison idealOp :: (a ~> b) -> (a ~> b) -> (a ~> b) idealOp p1 p2 = dup >>> decouple >>> (p1 +++ p2) It seems that for this case, decouple might be important. While they're running in lock step, p1 might yield but p2 might not. If you *want* their yields to be coupled, then instead try this: merge :: (a,a) ~> a merge = forever $ await >>= \(a,a') -> yield a >> yield a' idealOp :: (a ~> b) -> (a ~> b) -> (a ~> b) idealOp p1 p2 = (p1 &&& p2) >>> merge I'm writing in pseudo-code, but I hope what I'm saying is clear. -- Dan Burton On Tue, Apr 7, 2015 at 5:03 AM, Antonio Nikishaev <m...@lelf.lu> wrote: > > What is the sane way to do something like this? > > (await >>= \x -> yield (Left x) >> yield (Right x)) > >-> p1 +++ p2 > > Let's assume p1 or/and p2 are too complex to fit into Foldl. > > > -- > lelf > > -- > You received this message because you are subscribed to the Google Groups > "Haskell Pipes" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to haskell-pipes+unsubscr...@googlegroups.com. > To post to this group, send email to haskell-pipes@googlegroups.com. > -- You received this message because you are subscribed to the Google Groups "Haskell Pipes" group. To unsubscribe from this group and stop receiving emails from it, send an email to haskell-pipes+unsubscr...@googlegroups.com. To post to this group, send email to haskell-pipes@googlegroups.com.