David Sankel <[EMAIL PROTECTED]> writes:

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

Well, that is to ignore the possibility that if 'main' has arguments,
you can pattern-match directly on them, rather than using a more
verbose 'case' expression as is currently widely practiced after
'getArgs'.

However, as has already been mentioned, there is nothing to stop the
original poster defining a library wrapper such as

    withArgs :: ([String]->IO ()) -> IO ()
    withArgs = (>>=) getArgs

and then the "boilerplate" is simply

    main = withArgs main'

    main' []     = ...
    main' (x:xs) = ...

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

Again, some simple wrappers will do the job nicely.

    withProgArgsEnv :: (String -> [String] -> [(String,String)] -> IO ())
                       -> IO ()
    withProgArgsEnv main = do p <- getProgName
                              a <- getArgs
                              e <- getEnvironment       -- not standard
                              main p a e

Maybe a small set of such wrappers could be added to the hierarchical
libraries, if someone wants to do a little design.

Regards,
    Malcolm
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to