[Haskell] main::[String]->IO() ?

David Sankel camio at yahoo.com
Tue Mar 23 09:09:27 EST 2004


--- Steffen Mazanek <s_mazanek at gmx.de> wrote:
> I think this would simplify everyday-programming a lot. Or are there
> any severe theoretical (semantical) problems (main is running in the IO 
> monad either way)? 

The type signature of main currently is:

main :: IO()

and the new type signature would be

main :: [String] -> IO()

Since type signature declarations for functions are generally considered good
practice, those who use "<- getArgs" would actually need to type two extra
characters.  And those who do not use getArgs typically (which may or may not
be the case in general), would type an extra 14 characters.

One might also consider getProgName and getEnv to be plausible arguments to
main as they are for some variants of c.  However, in this case we are
getting quite excessive with main's arguments.

Aside from the two points made above, the current, no-argument version of
main would support new programming models elegantly.  Future systems
development may lead to better system-program communication.  GUI's, for
instance, might have a special configuration line of communication for window
placement which could be vastly superior to parsing a list of strings.

Although there aren't any theoretical problems with main having an argument,
I think that current practicioners would find it more efficient the way it is
now.

David J. Sankel


More information about the Haskell mailing list