chr throws unhelpful error messages
GHC.Char.chr
is utterly unhelpful at the moment:
chr :: Int -> Char
chr i@(I# i#)
| isTrue# (int2Word# i# `leWord#` 0x10FFFF##) = C# (chr# i#)
| otherwise
= errorWithoutStackTrace ("Prelude.chr: bad argument: " ++ showSignedInt (I# 9#) i "")
No stack trace and no explanation what exactly is so bad leaves users bewildered and helpless. A recent example is #21467 (closed).
I suggest we use error
instead of errorWithoutStackTrace
and provide a reason for rejection, e. g., "argument is outside of Unicode range".