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

Herbert Valerio Riedel hvr at gnu.org
Sat Dec 14 18:56:53 UTC 2013


On 2013-12-14 at 12:09:20 +0100, Vo Minh Thu wrote:

[...]

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

[...]

> Isn't your `die` function a special case of `error :: String -> a`,
> which is in the Prelude ?

Imho, it'd be more comparable to the effect of `fail :: Monad m =>
String -> m a` for 'm == IO' (which throws an 'userError' exception).

E.g.:

  $ cat > foo.hs <<EOF
  main = fail "I'm outta here"
  EOF
  
  $ ghc --make foo.hs
  
  $ ./foo.hs
  
  foo: user error (I'm outta here)




More information about the Libraries mailing list