Fergus Henderson <[EMAIL PROTECTED]> wrote:
| Second, how do you handle syntax errors in the command line arguments?
| What does lookupInt do if the integer overflows, or if the argument
| is not valid syntax for an integer? Do you check for misspelt or
| invalid option names?
The point Simon made is that you can still use all of the old stuff. You
can still define a function
getArgs :: IO Args
getArgs = return args
if you wish. And of course you can change that in just giving a warning at
the beginning of your program if the arguments aren't well defined. I've
always thought it is a good idea to make them a constant; what is the
point in having an IO function that always returns the same result?
Sverker Nilsson <[EMAIL PROTECTED]> wrote:
| Anyway, what it seems to me you lose by doing it the way you described
| is that you are stuck again if some day you want to set those flags
| some other way than from the environment variables. For example with
| pragmas. You can't compile several modules with different settings
| either, without restarting all of the compiler, it seems to me.
I think this is always a problem in pure functional programming. You
define a function and later on you discover that this function needs to
have an extra dependency. If this is causing a difficulty in further
developing your program (because this is difficult to change), then this
is due to bad programming or, if I may say, the paradigm that forces you
to do this.
This is also the case for making stdin a constant or not. I think stdin IS
a constant, and should stay that way. If some bad programmer wrote a
function that only worked on the stdin and stdout, than he limited the
users of his/her function to only use it for that purpose. He/she also
could have made two extra parameters for this function instead.
If you need awkward plumbing for this you can still hide it away by
abstracting it into another (reader) monad. I think we should see stdin
and stdout as static connections with the outside world, and make our own
abstractions in Haskell if we wish to, instead of using stdin and stdout
for that.
Regards,
Koen.
--
| Koen Claessen, [EMAIL PROTECTED] |
| http://www.cse.ogi.edu/~kcclaess/ |
|------------------------------------------------------|
| Visiting student at OGI, Portland, Oregon, USA. |