
From: "John M. Dlugosz"
(And that begs the question of why getArgs needs to be monadic in the first place. It doesn't change its value; it's a strict constant at run-time, and not knowing it at compile time is my problem how?)
Actually, the value of the arguments can be changed - at least on some platforms. They are writable from C, if nothing else. What should getArgs do if some ffi changes the arguments before it's called? Mike

On 04/14/2014 03:20 PM, Mike Meyer wrote:
From: "John M. Dlugosz"
mailto:ngnr63q02@sneakemail.com> (And that begs the question of why getArgs needs to be monadic in the first place. It doesn't change its value; it's a strict constant at run-time, and not knowing it at compile time is my problem how?) Actually, the value of the arguments can be changed - at least on some platforms. They are writable from C, if nothing else. What should getArgs do if some ffi changes the arguments before it's called?
You can do it right from within Haskell: Prelude> import System.Environment Prelude System.Environment> getArgs [] Prelude System.Environment> withArgs ["foo"] $ getArgs ["foo"] It's useful if you have a command-line interface and the user mistypes something; all you have to do is continue as if they passed "--help" instead of a separate code path.
participants (2)
-
Michael Orlitzky
-
Mike Meyer