[Haskell-cafe] Process properties as global values

Volker Wysk post at volker-wysk.de
Sun Jul 4 08:58:35 EDT 2004


Hi

I'm just wondering, why haven't process properties (such as the command
line arguments, or the parent process id), which are inherently global,
been made global values in the Haskell standard? You could avoid
needlessly carrying around these values, you wouldn't need to lift some
functions into the IO monad...

For instance, command line argument parsing could look something like
this:


import qualified System

data ParsedArgs = ParsedArgs { pa_myflag :: Bool; ... }
                | Failure

parsed_args :: ParsedArgs
parsed_args = (... using System.argv ...)

myflag = pa_myflag parsed_args


main = do
   when (parsed_args == Failure) $ ...
   ...


You can get the same effect by using unsafePerformIO. It would still be
nice having this in the standard.

Greetings,
V.W.

--
Volker Wysk <post at volker-wysk.de>
http://www.volker-wysk.de



More information about the Haskell-Cafe mailing list