I use Haskell stream processing library pipes to write a command line tool. Each command line actions may output result to stdout
and logs to stderr
wi
(This is @Michael's answer, but I'd like to write it up here so we can move the question out of the unanswered queue for the Haskell tag.)
See (+++)
in pipes-extras. Keep in mind a Consumer
is a Pipe
(to nowhere), so P.toHandle IO.stderr +++ P.stdoutLn :: MonadIO m => Pipe (Either String String) (Either b d) m ()
.
To get a Consumer
, you would have to get rid of the Lefts
e.g with >-> P.concat
or >-> P.drain
. There are more robust and handsome ways of doing this with Fold
s.