<div dir="ltr">While I used to use cmdargs, at some point I switched to optparse-applicative and never strayed. My only complain about it is that it uses strings everywhere instead of text.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 5, 2015 at 1:43 PM, Vale Cofer-Shabica <span dir="ltr"><<a href="mailto:vale.cofershabica@gmail.com" target="_blank">vale.cofershabica@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello all,<br>
<br>
Punchline first: What's the "best practice" way of doing unix-style<br>
command line argument and file input processing in Haskell?<br>
<br>
Background:<br>
I'm using Haskell to write programs that act like well-behaved,<br>
pipe-friendly unix tools. i.e., the following are all equivalent:<br>
<br>
% ./prog file<br>
% ./prog < file<br>
% cat file | ./prog<br>
<br>
Thus far, I've done this by directly inspecting the first element of<br>
System.Environment.getArgs, which has been fine thus far.<br>
<br>
I'd also like to be able to take simple command line arguments<br>
(boolean flags and numeric parameters) and the above doesn't adapt<br>
well to that case. I'd like to do this in the idiomatic, "standard"<br>
way (a la getopt() in C). Browsing through the wiki page on command<br>
line argument parsers [1] gave me a bewildering array of options. I'm<br>
not really sure where to start, though I remember reading a blanket<br>
endorsement of optparse-applicative somewhere.<br>
<br>
Any pointers or examples that address my use-case would be much appreciated.<br>
<br>
-vale<br>
<br>
[1]: <a href="https://wiki.haskell.org/Command_line_option_parsers" target="_blank">https://wiki.haskell.org/Command_line_option_parsers</a><br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div>