Re: Decorating exceptions with backtrace information

ben, could you please email the libraries list with this too? This seems
like a core libraries / base change rather than a ghc-the-compiler change
On Thu, May 7, 2020 at 6:57 PM Michael Sloan
Thanks so much for making a proposal for this, Ben!! It's great to see progress here.
I'm also glad that there is now a proposal process. I made a fairly similar proposal almost exactly 5 years ago to the libraries list - https://mail.haskell.org/pipermail/libraries/2015-April/025471.html - but without the subtlety of particular backtrace representations. Skimming the ensuing thread may still be informative.
In particular, there is one thing I would like to highlight from that old proposal. I think it'd be good to have a standard way to represent a chain of exceptions, and build this into `catch` and `finally`. Python and Java both have a mechanism for this, and both refer to it as a "cause" exception. When an exception is thrown during exception handling, the exception being handled is preserved as its "cause". I find this mechanism to be incredibly useful in Java, it has made the underlying issue much clearer in many cases, and in other cases at least provides helpful context. I have no doubt such a mechanism would have saved me many hours of debugging exceptions in Haskell systems I've worked on in the past.
I considered commenting about that directly on the proposal, but I figure this is a better place to suggest expanding the scope of the change :) . Totally understandable if you want to keep this proposal focused on stacktraces, but I think it'd be good to consider this as a potential future improvement.
-Michael
On Thu, May 7, 2020 at 3:55 PM Ben Gamari
wrote: Hi everyone,
After a nice discussion on IRC about the unfortunate state of error reporting in Haskell, I felt compelled to write down some long-lingering thoughts regarding backtraces on exceptions. The result is GHC proposal #330 [1]. I think the approach is viable and perhaps even straightforward. I have the sketch of an implementation here [2].
Please have a look at the proposal and leave your comments. If there is consensus it is possible that we could have this done for 8.12.
Cheers,
- Ben
[1] https://github.com/ghc-proposals/ghc-proposals/pull/330 [2] https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3236 _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

On Fri, May 8, 2020 at 9:32 AM Carter Schonwald
ben, could you please email the libraries list with this too? This seems like a core libraries / base change rather than a ghc-the-compiler change
On Thu, May 7, 2020 at 6:57 PM Michael Sloan
wrote: Thanks so much for making a proposal for this, Ben!! It's great to see progress here.
I'm also glad that there is now a proposal process. I made a fairly similar proposal almost exactly 5 years ago to the libraries list - https://mail.haskell.org/pipermail/libraries/2015-April/025471.html - but without the subtlety of particular backtrace representations. Skimming the ensuing thread may still be informative.
In particular, there is one thing I would like to highlight from that old proposal. I think it'd be good to have a standard way to represent a chain of exceptions, and build this into `catch` and `finally`. Python and Java both have a mechanism for this, and both refer to it as a "cause" exception. When an exception is thrown during exception handling, the exception being handled is preserved as its "cause". I find this mechanism to be incredibly useful in Java, it has made the underlying issue much clearer in many cases, and in other cases at least provides helpful context. I have no doubt such a mechanism would have saved me many hours of debugging exceptions in Haskell systems I've worked on in the past.
I considered commenting about that directly on the proposal, but I figure this is a better place to suggest expanding the scope of the change :) . Totally understandable if you want to keep this proposal focused on stacktraces, but I think it'd be good to consider this as a potential future improvement.
-Michael
On Thu, May 7, 2020 at 3:55 PM Ben Gamari
wrote: Hi everyone,
After a nice discussion on IRC about the unfortunate state of error reporting in Haskell, I felt compelled to write down some long-lingering thoughts regarding backtraces on exceptions. The result is GHC proposal #330 [1]. I think the approach is viable and perhaps even straightforward. I have the sketch of an implementation here [2].
Please have a look at the proposal and leave your comments. If there is consensus it is possible that we could have this done for 8.12.
Cheers,
- Ben
[1] https://github.com/ghc-proposals/ghc-proposals/pull/330 [2] https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3236 _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

There seem to be multiple beginnings of the discussion. What is currently discussed? If someone says "exceptions" and "backtrace" in one sentence, I suspect like many times before, that again confusion of the concepts of exceptions and errors is ahead. Errors already support call stacks. Why should exceptions get them, too? Exceptions should carry information that is useful for a user, but a callstack is not useful for a user. I can imagine that it would be helpful for the user to get a stacked exception information like: Parse error on line 42, column 23 while reading file "foo/bar" while traversing directory "blabla" But since you refer to the CallStack feature of GHC, this seems not to be addressed in the proposals. On Fri, 8 May 2020, Carter Schonwald wrote:
I have no doubt such a mechanism would have saved me many hours of debugging exceptions in Haskell systems I've worked on in the past.
If you must debug exceptions, then this sounds like exceptions were abused for programming errors. Ben writes in: http://www.well-typed.com/blog/2020/04/dwarf-3/ "Unfortunately, the untyped nature of Haskell exceptions complicates the migration path for existing code." Actually, it only proves again, that it was wrong from the beginning to hide information about potential exceptions in the IO monad instead of making them explicit via ExceptionalT, ExceptT or the like.
participants (2)
-
Carter Schonwald
-
Henning Thielemann