The type you mention foldToProducer :: Monad m => (x -> a -> x) -> x -> (x -> b) -> Producer a m r -> Producer b m r
could be doing one of two things. It could be a scan, which appears as a pipe in Pipes.Prelude P.scan :: Monad m => (x -> a -> x) -> x -> (x -> b) -> Pipe a b m r so \op seed out p -> p >-> P.scan op seed out :: Monad m => (x -> b -> x) -> x -> (x -> b) -> Producer a m r -> Producer b m r -- specializing a bit But it seems you want to fold, but then yield the single result. (This is effectively what folds is doing, repeatedly for each of the successive producers in a FreeT (Producer a m) m r. But the simple case is pretty straightforward with the asterisked fold' in Pipes.Prelude: P.fold' :: Monad m => (x -> a -> x) -> x -> (x -> b) -> Producer a m r -> m (b, r) foldToProducer :: Monad m => (x -> a -> x) -> x -> (x -> b) -> Producer a m r -> Producer b m r foldToProducer op seed out p = do (b,r) <- lift $ P.fold' op seed out p yield b return r I don't know if there would be a swanker way of doing it just with standard combinators. But is that more like what you mean? -- 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.