
On Sat, Dec 14, 2013 at 12:09:20PM +0100, Vo Minh Thu wrote:
Isn't your `die` function a special case of `error :: String -> a`, which is in the Prelude ?
No, it's not. I'm not going into the details of imprecise exceptions (and GHC's interpretation of them + all the bugs that various versions of GHC have when it comes to that topic), but `error` indicates a programmer error and should not be part of a valid path in your program. In contrast, `die` is meant to be used when a user e.g. passes wrong input to a program (which is a user error, not a programmer error).
I think variants of what you propose are often used: different exit codes, not exiting and flushing stderr
You can just use hPutStrLn here, stderr is unbuffered by default.
displaying an arbitrary `Show a` instead of `String`
Yes, that is actually a good point. But die (show x) is still much more concise than using hPrint + exitFailure.
using `Text`
Valid point. Still, I think for the particular case of error messages it's ok to stick with String. Cheers.