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

Mike Meyer mwm at mired.org
Tue May 5 18:07:43 UTC 2015


On Tue, May 5, 2015 at 12:58 PM, Michael Orlitzky <michael at orlitzky.com>
wrote:

> 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.
>

I also use CmdArgs, though I'm not positive it's still the best choice.
eddie (http://chiselapp.com/user/mwm/repository/eddie/doc/tip/README.md)
correctly handles the cases you want, and in additions makes:

$ cat cat file1 file2 file3 | ./prog
$ ./prog file1 file2 file3

do the same thing. However, it's a bit complicated, as eddie has multiple
interacting options, an accumulating option, and defaults the first
argument to an option and the rest to files to be processed. Figure out the
simpler examples first.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150505/7693ce08/attachment.html>


More information about the Beginners mailing list