Let's say I have two Proxy
in Haskell Pipes. They represent external system processes.
produce :: MonadIO m => Producer ByteString m ExitCode
consume :: MonadIO m => Consumer ByteString m ExitCode
So I hook them into an Effect
, like this:
effect :: Effect m ExitCode
effect = produce >-> consume
This Effect
is going to give me the ExitCode
from the first Proxy
that terminates. Ordinarily this will be the produce
, not the consume
. What's the idiomatic Pipes way to get the return value of the consume
even if it does not terminate first?
So far I am thinking this is not possible without doing some sort of icky in-band signaling so the consume
knows the stream is done. The only way the last Proxy knows to shut down is by getting something from an await
, so I could send it an empty ByteString
to signal that the stream is done. That just doesn't feel right though. What I've got now is a separate MVar that can provide the exit value but I'm thinking there has to be a more idiomatic way to do this.