<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 10, 2015 at 9:45 PM, Dan Stromberg <span dir="ltr"><<a href="mailto:strombrg@gmail.com" target="_blank">strombrg@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br clear="all"><div>If I want to read a list of filenames, each terminated with a nul byte, from stdin (kind of like xargs -0), what's the best way to do that in Haskell?  Or am I swimming against the current to do anything but newline-termination?</div><div><br></div><div>Google's top hit is:</div><div><a href="https://downloads.haskell.org/~ghc/7.6.1/docs/html/libraries/bytestring-0.10.0.0/Data-ByteString.html" target="_blank">https://downloads.haskell.org/~ghc/7.6.1/docs/html/libraries/bytestring-0.10.0.0/Data-ByteString.html</a><br></div><div>...but I don't see anything about nul termination there.  I checked the top ~5 hits, and didn't find much.</div><div><br></div><div>I also checked <a href="https://www.haskell.org/hoogle/?hoogle=Lines" target="_blank">https://www.haskell.org/hoogle/?hoogle=Lines</a></div><div><br></div><div>The goal is to be able to operate on filenames that contain newlines, but it's not that end of the world if that isn't very practical.</div><div><br></div><div>Thanks!</div><span class=""><font color="#888888"><div><br></div>-- <br><div>Dan Stromberg</div>
</font></span></div>
<br><br></blockquote><div><br></div><div>To give you an idea of how this might be done, I put together an example using the conduit-combinators library:<br><br><a href="https://gist.github.com/snoyberg/2a5ca79d97f483bdcfe9">https://gist.github.com/snoyberg/2a5ca79d97f483bdcfe9</a><br><br></div><div>This can be done in a more low-level manner by using the bytestring library directly, which will require learning less new concepts. However, streaming libraries like conduit and pipes are specifically designed for handling these kinds of problems. There's a tutorial on conduit available at:<br><br><a href="https://github.com/snoyberg/conduit#readme">https://github.com/snoyberg/conduit#readme</a><br><br></div><div>Michael <br></div></div></div></div>