[Haskell-cafe] Re: [Haskell] Re: Why is getArgs in the IO monad?

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Tue Jan 18 19:12:36 EST 2005

Keean Schupke <k.schupke at imperial.ac.uk> writes:

> Surely both requirements can be satisfied if the programs arguments are made
> parameters of main:
> main :: [String] -> IO ()

>From info '(libc)Error Messages', about program_invocation_name
and program_invocation_short_name:

   *Portability Note:* These two variables are GNU extensions.  If you
want your program to work with non-GNU libraries, you must save the
value of `argv[0]' in `main', and then strip off the directory names
yourself.  We added these extensions to make it possible to write
self-contained error-reporting subroutines that require no explicit
cooperation from `main'.

This suggests that making global parameters available only as
arguments of main would be a bad idea. But they should be settable,
to account for the rare case of wanting to substitute something else
to a library which reads them itself.

   __("<         Marcin Kowalczyk
   \__/       qrczak at knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/

More information about the Haskell-Cafe mailing list