shorter error messages

Is there a way to tell ghc to print errors, especially type errors in a more concise way? Ideally one or two lines of text? I hate it when I have to scroll several pages of text just to see the next/previous error location. Cheers Ben -- Niemand hat das Recht zu gehorchen. -- Hannah Arendt

I don’t think so! But it’s a great idea perhaps! How do other tools do it?
And or is there a bread crumb you could do find next/previous match on the
current output for? Or is that missing and the real issue to address?
On Tue, Mar 16, 2021 at 9:02 AM Ben Franksen
Is there a way to tell ghc to print errors, especially type errors in a more concise way? Ideally one or two lines of text? I hate it when I have to scroll several pages of text just to see the next/previous error location.
Cheers Ben -- Niemand hat das Recht zu gehorchen. -- Hannah Arendt
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

I've found this problem to be largely solved when using the haskell language server with the emacs lsp mode — it just marks whatever call would throw a type error and gives you a (usually) reasonably short hint of what went wrong. So far I've also not seen any false alerts — but then I've only been using it for a week or so, so maybe I just haven't run into them yet. Of course, this doesn't really help if you really want to just use ghc by itself, but perhaps it would be possible to write some minimal client for the language server which just shows you the errors? Barring that, I guess you /could/ do something like $ ghc 2>&1 | grep "Couldn't match" -A 4 to get a list of type errors, but that's rarely actually useful ... stuebinm On 16.03.21 16:21, Carter Schonwald wrote:
I don’t think so! But it’s a great idea perhaps! How do other tools do it? And or is there a bread crumb you could do find next/previous match on the current output for? Or is that missing and the real issue to address?
On Tue, Mar 16, 2021 at 9:02 AM Ben Franksen
mailto:ben.franksen@online.de> wrote: Is there a way to tell ghc to print errors, especially type errors in a more concise way? Ideally one or two lines of text? I hate it when I have to scroll several pages of text just to see the next/previous error location.
Cheers Ben -- Niemand hat das Recht zu gehorchen. -- Hannah Arendt
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

In any case, the haskell language server just uses GHC internally, so it just shortens the GHC message. But then I believe the same result could be accomplished by some simple text manipulation on GHC's normal output.
- Tom
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, March 16, 2021 4:58 PM, stuebinm via Haskell-Cafe
I've found this problem to be largely solved when using the haskell language server with the emacs lsp mode — it just marks whatever call would throw a type error and gives you a (usually) reasonably short hint of what went wrong. So far I've also not seen any false alerts — but then I've only been using it for a week or so, so maybe I just haven't run into them yet.
Of course, this doesn't really help if you really want to just use ghc by itself, but perhaps it would be possible to write some minimal client for the language server which just shows you the errors?
Barring that, I guess you /could/ do something like $ ghc 2>&1 | grep "Couldn't match" -A 4 to get a list of type errors, but that's rarely actually useful ...
stuebinm
On 16.03.21 16:21, Carter Schonwald wrote:
I don’t think so! But it’s a great idea perhaps! How do other tools do it? And or is there a bread crumb you could do find next/previous match on the current output for? Or is that missing and the real issue to address? On Tue, Mar 16, 2021 at 9:02 AM Ben Franksen
wrote: Is there a way to tell ghc to print errors, especially type errors in a more concise way? Ideally one or two lines of text? I hate it when I have to scroll several pages of text just to see the next/previous error location.
Cheers Ben -- Niemand hat das Recht zu gehorchen. -- Hannah Arendt
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

On 16-03-2021 17:40, Tom Smeding wrote:
In any case, the haskell language server just uses GHC internally, so it just shortens the GHC message. But then I believe the same result could be accomplished by some simple text manipulation on GHC's normal output.
In fact, you can use -ddump-json to get JSON error messages. I should be easy to convert that to any form you like. But there is no clear specification of that output: https://gitlab.haskell.org/ghc/ghc/-/issues/19278 And I also want to point out that there is a big open issue for better error messages: https://gitlab.haskell.org/ghc/ghc/-/issues/8809

There is no "official" way to accommodate this reasonable request. The ideas up-thread are good ones. I want to pipe in that we're currently going through an internal overhaul of error-message handling that will make such a request much easier to contemplate in the future. This is active work going on right now. So there is hope, possibly for 9.4. Of course, once the internal overhaul is done, we'll need to design any features that actually change the output -- the overhaul just makes it easy to implement such features (which would be very difficult at the moment). Richard
On Mar 16, 2021, at 12:56 PM, Jaro Reinders
wrote: On 16-03-2021 17:40, Tom Smeding wrote:
In any case, the haskell language server just uses GHC internally, so it just shortens the GHC message. But then I believe the same result could be accomplished by some simple text manipulation on GHC's normal output.
In fact, you can use -ddump-json to get JSON error messages. I should be easy to convert that to any form you like.
But there is no clear specification of that output: https://gitlab.haskell.org/ghc/ghc/-/issues/19278
And I also want to point out that there is a big open issue for better error messages: https://gitlab.haskell.org/ghc/ghc/-/issues/8809 _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Am 16.03.21 um 19:07 schrieb Richard Eisenberg:
There is no "official" way to accommodate this reasonable request. The ideas up-thread are good ones.
Thanks everyone for the many suggestions. I am using cabal to build. Vim and emacs and IDEs are not in my toolbox for various reasons. Of course I can do shell hacking to filter the messages, just wanted to ask if there is a more convenient way.
I want to pipe in that we're currently going through an internal overhaul of error-message handling that will make such a request much easier to contemplate in the future. This is active work going on right now. So there is hope, possibly for 9.4. Of course, once the internal overhaul is done, we'll need to design any features that actually change the output -- the overhaul just makes it easy to implement such features (which would be very difficult at the moment).
Looking forward to that! It seems I am not the only one who would, occasionally, prefer to get error messages in a more condensed form. Cheers Ben

On Tue, 16 Mar 2021, Ben Franksen wrote:
Is there a way to tell ghc to print errors, especially type errors in a more concise way? Ideally one or two lines of text? I hate it when I have to scroll several pages of text just to see the next/previous error location.
It has become especially worse since undefined identifiers are now sometimes handled by the type checker. A simple "xyz is not defined" can now consume many pages of follow-up type errors.

Huh! When does that happen? I thought that’s only with leading underscore for typed hole syntax On Tue, Mar 16, 2021 at 11:40 AM Henning Thielemann < lemming@henning-thielemann.de> wrote:
On Tue, 16 Mar 2021, Ben Franksen wrote:
Is there a way to tell ghc to print errors, especially type errors in a more concise way? Ideally one or two lines of text? I hate it when I have to scroll several pages of text just to see the next/previous error location.
It has become especially worse since undefined identifiers are now sometimes handled by the type checker. A simple "xyz is not defined" can now consume many pages of follow-up type errors. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
participants (7)
-
Ben Franksen
-
Carter Schonwald
-
Henning Thielemann
-
Jaro Reinders
-
Richard Eisenberg
-
stuebinm
-
Tom Smeding