[Haskell-cafe] Use of errorWithoutStackTrace in the Prelude

Alexis King lexi.lambda at gmail.com
Wed Dec 7 00:30:21 UTC 2016


Hello,

I noticed that the partial functions in the Prelude use
errorWithoutStackTrace instead of `error` to provide their error
messages, which produces significantly worse error messages. I
stumbled into this when a coworker of mine had trouble tracking
down a use of `head` that was throwing an exception, but didn’t
include any information about where it was in the source.

What exactly is the rationale for this? Is it to avoid the performance
penalty of passing around the implicit parameter? That seems
relatively unlikely, since the performance hit seems trivial, but
perhaps it’s to avoid breaking tests that depend on error messages?
I think it would be nice for Prelude-provided functions to be
informative by default, so the change seems worth it to me, but I’m
wondering if there’s something I’ve overlooked.

Also, if the answer really is “no, errorWithoutStackTrace is correct”,
is the expectation that people will use -prof if they want stacks?
This seems a bit frustrating to a newcomer who might not understand
anything more complicated than running `stack test` and might not
be able to figure out how to pass the right options (especially
since options need to be passed both at compile-time and at runtime).

Thanks,
Alexis


More information about the Haskell-Cafe mailing list