[Haskell-beginners] how to access command line arguments

Marc Weber marco-oweber at gmx.de
Sat Aug 14 23:59:39 EDT 2010


Excerpts from prad's message of Sun Aug 15 05:39:00 +0200 2010:
> is the former the better way to do it then? or are there other
> alternatives?
 
If you don't want to use existing option parsers I'd recommend this
style:

args <- getArgs
case args of
  first:last:z -> ...
  _ -> show_usage

where show_usage = print "expected arguments: first last z"

this way you can "die cracefully" if options are passed the program
it didn't expect.

Marc Weber


More information about the Beginners mailing list