I don't believe detecting upstream termination is possible with pipes alone.
You can check into pipes-parse, which provides *isEndOfInput* https://www.stackage.org/haddock/lts-9.5/pipes-parse-3. 0.8/Pipes-Parse.html#v:isEndOfInput Or you can try conduit with *await*, which returns Nothing if the upstream source has terminated https://www.stackage.org/haddock/lts-9.5/conduit-1.2. 12/Data-Conduit.html#v:await Contrast with the *await* from pipes, which does not grant the opportunity to recover from upstream termination https://www.stackage.org/haddock/lts-9.5/pipes-4.3.4/Pipes.html#v:await If you don't mind stepping the producer yourself, you can try using *next* from pipes https://www.stackage.org/haddock/lts-9.5/pipes-4.3.4/Pipes.html#v:next -- Dan Burton On Wed, Sep 20, 2017 at 8:21 AM, Merijn Verstraaten <mer...@inconsistent.nl> wrote: > Hi, > > In my current code I have a "myPipe :: Pipe Foo Bar m r" (that consumes > any number of inputs) and a "myProd :: Producer Bar m r" (that produces a > finite number of outputs) that I want to combine so that the Producer runs > after the pipe exhausts all it's input. Given an "inputProducer :: Producer > Foo m r" I can write "(inputProducer >-> myPipe) >> myProd" to get the > desired effect, but this is horrible thing for users of my code to have to > write. > > Is there any way I can achieve this reasonably nicely? Ideally I'd like > some way to combine my pipe and producer into a single "Pipe Foo Bar m r" > in various ways (like returning my producer from the pipe and calling > join), but since the pipe consumes any number of inputs that just results > in my producer never running. Any suggestions? > > Cheers, > Merijn > > -- > 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.