On Tue, May 5, 2015 at 12:58 PM, Michael Orlitzky <michael@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.