[Haskell-beginners] Unix-style command line arguments and file input?
Michael Orlitzky
michael at orlitzky.com
Tue May 5 17:58:58 UTC 2015
On 05/05/2015 01:43 PM, Vale Cofer-Shabica 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 use CmdArgs for this. I think the simplest example is,
https://hackage.haskell.org/package/email-validator
And one with multiple modes:
https://hackage.haskell.org/package/hath
It's not *quite* what you asked for: I use e.g. `hath -i file` to mean
the same thing as `hath < file`, but that's as close as I got.
More information about the Beginners
mailing list