Proposal: die to System.Exit (and/or Prelude)

Henning Thielemann lemming at
Sat Dec 14 11:38:13 UTC 2013

On Sat, 14 Dec 2013, Simon Hengel wrote:

> Hi!
> I propose to add
>    die :: String -> IO ()
>    die err = hPutStrLn stderr err >> exitFailure
> to System.Exit.

I have written this definition several times and called it exitFailureMsg. 
I used it only for the argument handling in shell programs. I agree with 
Roman that the proper way are exceptions. However, the implicit nature of 
IO exceptions is the wrong way, too. This is confirmed by Roman's 
observation that it is not clear how uncaught IO exceptions are handled. 
In an explicit ErrorT way you cannot accidentally ignore exceptions.

Thus, I think neither 'die'/exit nor IO exceptions are the right way to 
go. Consequently I hesitate to add further steps in wrong directions to 
'base'. Maybe it would be better to add an exception handler containing 
"hPutStrLn stderr" to ErrorT module.

> Add System.Exit.die:


> Re-export it from Prelude:


More information about the Libraries mailing list