[Haskell-beginners] Unix-style command line arguments and file input?

David McBride toad3k at gmail.com
Tue May 5 18:12:58 UTC 2015


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.

On Tue, May 5, 2015 at 1:43 PM, Vale Cofer-Shabica <
vale.cofershabica at gmail.com> wrote:

> Hello all,
>
> Punchline first: What's the "best practice" way of doing unix-style
> command line argument and file input processing in Haskell?
>
> Background:
> I'm using Haskell to write programs that act like well-behaved,
> pipe-friendly unix tools. i.e., the following are all equivalent:
>
> % ./prog file
> % ./prog < file
> % cat file | ./prog
>
> Thus far, I've done this by directly inspecting the first element of
> System.Environment.getArgs, which has been fine thus far.
>
> I'd also like to be able to take simple command line arguments
> (boolean flags and numeric parameters) and the above doesn't adapt
> well to that case. I'd like to do this in the idiomatic, "standard"
> way (a la getopt() in C). Browsing through the wiki page on command
> line argument parsers [1] gave me a bewildering array of options. I'm
> not really sure where to start, though I remember reading a blanket
> endorsement of optparse-applicative somewhere.
>
> Any pointers or examples that address my use-case would be much
> appreciated.
>
> -vale
>
> [1]: https://wiki.haskell.org/Command_line_option_parsers
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150505/ec91700f/attachment-0001.html>


More information about the Beginners mailing list