[GHC] #8809: Prettier error messages?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
75 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

[GHC] #8809: Prettier error messages?

GHC - devs mailing list
#8809: Prettier error messages?
------------------------------------+-------------------------------------
       Reporter:  joelteon          |             Owner:
           Type:  feature request   |            Status:  new
       Priority:  normal            |         Milestone:
      Component:  Compiler          |           Version:  7.9
       Keywords:                    |  Operating System:  Unknown/Multiple
   Architecture:  Unknown/Multiple  |   Type of failure:  None/Unknown
     Difficulty:  Unknown           |         Test Case:
     Blocked By:                    |          Blocking:
Related Tickets:                    |
------------------------------------+-------------------------------------
 `clang` has very nice-looking error messages.


 {{{
 #!html
 <pre><span style="font-weight: bold">pretty.c:6:7: <span style="color:
 pink">warning:</span> incompatible pointer to integer conversion passing
 'char [14]' to parameter of type 'int' [-Wint-conversion]</span>
   foo("Hello, world!");
       <span style="color: green">^~~~~~~~~~~~~~~</span>
 <span style="font-weight: bold">pretty.c:1:14: note: passing argument to
 parameter 'i' here</span>
 void foo(int i) {
              <span style="color: green">^</span>
 1 warning generated.</pre>
 }}}

 `ghc`'s error messages are not so good.

 {{{
 #!html
 <pre>ugly.hs:7:18:
     Couldn't match expected type &lsquo;()&rsquo; with actual type
 &lsquo;[Char]&rsquo;
     In the first argument of &lsquo;f&rsquo;, namely &lsquo;"Hello,
 world!"&rsquo;
     In the second argument of &lsquo;($)&rsquo;, namely &lsquo;f "Hello,
 world!"&rsquo;
     In the expression: print $ f "Hello, world!"</pre>
 }}}

 In my opinion, there are three independent improvements that could be made
 to GHC error messages and warnings: color, context and whitespace.
 Currently they're blobs of text.

 Consider all three applied to error messages:

 {{{
 #!html
 <pre><strong>ugly.hs:7:18: <span style="color: red">error:</span> Argument
 to 'f' is type '[Char]' but expected 'Int'</strong>
 main = print $ f "Hello, world!"
                  <span style="color: green">^~~~~~~~~~~~~~~</span>

 <strong>ugly.hs:3:1: note: type of 'f' is given here:</strong>
 f :: () -> IO ()
      <span style="color: green">^~</span></pre>
 }}}
 or

 {{{
 #!html
 <pre><strong>ugly.hs: note: type of 'f' is inferred:</strong>
 f :: forall m. Monad m => () -> m ()
                           <span style="color: green">^~</span></pre>
 }}}

 In my opinion, context and whitespace are more important that color. Even
 without color, compare this error message to the one shown above:

 {{{
 ugly.hs:7:18: error: Argument to 'f' is type '[Char]' but expected 'Int'
 main = print $ f "Hello, world!"
                  ^~~~~~~~~~~~~~~

 ugly.hs:3:1: note: type of 'f' is given here:
 f :: () -> IO ()
      ^~
 }}}

 In my opinion this is much easier to visually process than GHC's current
 messages.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+------------------------------------
        Reporter:  joelteon          |            Owner:
            Type:  feature request   |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:  7.9
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by schyler):

 Improving the prettiness of GHC errors is a great way to make it
 friendlier for people to pick up Haskell. Punting for this.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+------------------------------------
        Reporter:  joelteon          |            Owner:
            Type:  feature request   |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:  7.9
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by goldfire):

 I'm afraid I don't quite see what you're getting at. The original post
 says, "[This modified version] is much easier to visually process than
 GHC's current messages." My question is: Why, precisely? I don't mean to
 be defensive or dismissive, but trying to generate grounds for a
 meaningful conversation. For example, here are a few things that you might
 be getting at:

 * Having different colors/font weights (i.e. boldness) makes the error
 messages more visually interesting and therefore easier to pay attention
 to and read.
 * Having blank lines in the middle of single error messages makes them
 less imposing.
 * Using position marker in a line below some code is easier to follow than
 an ever-growing context.
 * In the example, the type of `f` is given explicitly, so the context in
 which the error was made is more apparent.

 Short of re-engineering the entire way that GHC handles error messages, it
 would certainly be hard to produce exactly the output that you are
 requesting. But, it may be possible to address bulletpoints like my
 suggested ones above piecemeal and nudge ourselves in the direction of
 better errors.

 It's also worth pointing out that each of the bulletpoints above has
 reasons "against", such as:

 * Not every terminal supports these extra modes. In particular, GHC has
 already had some trouble getting "smart" quotes working in all possible
 environments (or, indeed, figuring out when to fall back onto dumb
 quotes).
 * An automated processor of error messages (that is, an IDE built around
 GHC) could easily get confused around the blank lines. In fact, I believe
 I've run into this exact problem when running clang from emacs -- the
 extra "context-setting" output gets interpreted as fresh warnings.
 * It's unclear to me, personally, if having the position marker on a
 separate line is necessarily better than the current output.
 * The user of a DSL in Haskell is generally unaware of the full, general
 type of a function they are using. Perhaps including the full type in the
 error message would make it scarier, not friendlier.

 In any case, I'm curious to hear more about the specific things GHC can do
 to improve. I think we all want "better" error messages, but we need to
 agree on a definition of "better" first. And, the changes should probably
 be incremental, unless we have an eager volunteer to examine the whole
 error-message generation mechanism holistically. There is quite a bit of
 code dedicated to error messages, so this is not a task to be taken on
 lightly!

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by bgamari):

 Edsko and I were thinking about this a bit in light of the recent
 discussion on Reddit. He had what I thought was a rather nice idea:

 Putting aside the specific proposal made in this ticket, it seems like
 generally what we need is a more semantically-rich representation for our
 error messages. This need not be a giant AST encoding every possible error
 that might arise. Our current approach of encoding messages in `SDoc`
 works fairly well. What it lacks is the ability to denote meaningful
 references to various parts of the program (e.g. types, expressions,
 constraints).

 A moderately painless(?) way to fix this would be to index `Doc` (and
 `SDoc`) on a type which could then be embedded in the document. To put it
 concretely,
 {{{#!hs
 data Doc a = Embed a
            | Empty
            | NilAbove Doc
            .
            .
            .
 }}}

 The `Embed` constructor could then be used to embed various compiler-phase
 specific atoms into the document. For instance, the type-checker might
 emit errors in the form of `SDoc TcDoc` where,
 {{{#!hs
 data TcDoc = TcExprDoc CoreExpr
            | TypeDoc TcType
            | InstancesDoc ClsInstLookupResult
            .
            .
            .
 }}}

 Consumers of error messages could then use these annotations as they like.
 Most of the existing consumers would likely expose a function which would
 take a function to project the phase-specific data back to a plain `SDoc`.
 For instance,
 {{{#!hs
 showSDoc' :: DynFlags -> (a -> SDoc ()) -> SDoc a -> String
 }}}
 and we could avoid breaking existing users of `showSDoc` by defining it
 as,
 {{{#!hs
 showSDoc :: Outputable a => DynFlags -> SDoc a -> String
 showSDoc dflags = showSDoc' dflags ppr
 }}}

 Other uses (say, tooling using the GHC API) might choose to instead use a
 richer presentation of the data embedded in the document. These users will
 still be limited by the fact that the error representation is still
 ultimately a pretty-printer document, but at least now we can avoid
 parsing text. Moreover, we might be able to expose more context in this
 embedded data than we show in the current messages.

 One of the nice properties of this approach is that it allows a somewhat
 gradual transition. Adding the infrastructure to enable this sort of
 embedded doesn't requires only minor changes to existing code (e.g. adding
 the index to `SDoc`). Moreover, I have a sneaking suspicion that it would
 allow us to clean up the handling of `Name`s in `Outputable`.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
Changes (by bgamari):

 * cc: bgamari (added)


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by goldfire):

 It's
 [https://www.reddit.com/r/haskell/comments/3bnpa7/compiler_errors_for_humans/
 come to my attention] that my comment:2 may have shut down the
 conversation here. That was the opposite of my intent! I'd love to figure
 out how to break down the problem of difficult-to-work-with error messages
 into its pieces so that we can debate them (and hopefully implement
 improvements) sensibly.

 I should also be clear on one particular point: the biggest barrier to
 getting this done is the love from someone(s) to see it all through. This
 would be a valuable service, indeed.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by diatchki):

 It would be nice if we could refactor GHC so that error messages are kept
 in some sort of structured format with all information that might be
 relevant.  Then, when printed we could have flags to specify how to render
 the errors (e.g., "machine form", which would be good for external tools,
 such as IDEs; or "human form", which could have the nice formatting in the
 example).

 I just saw a post about error messages in Elm, which looked pretty, and
 might give us ideas about formatting:  http://elm-lang.org/blog/compiler-
 errors-for-humans

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by bgamari):

 Replying to [comment:6 diatchki]:
 > It would be nice if we could refactor GHC so that error messages are
 kept in some sort of structured format with all information that might be
 relevant.  Then, when printed we could have flags to specify how to render
 the errors (e.g., "machine form", which would be good for external tools,
 such as IDEs; or "human form", which could have the nice formatting in the
 example).
 >
 Indeed this would be nice, however placing all of the information
 necessary for an error comes at a cost. I think Simon PJ articulates this
 fairly well in this [[comment
 https://www.reddit.com/r/haskell/comments/3bnpa7/compiler_errors_for_humans/csoksqg]]
 on the Reddit post mentioned by goldfire (reproduced here for archival
 sake),

 >Building error messages from strings (or in GHC's case `SDoc`s) is pretty
 lame because you can write them but not analyse them. The "obvious"
 alternative is to use a huge algebraic data type with one constructor for
 each error message that GHC can produce. Then you generate the constructor
 in one place, and render it into a string somewhere else, perhaps in more
 than one way. I am not optimistic about this, because it puts a big
 central road-block in the way of generating error messages, and splits the
 work into two different places (the renderer and the generator). That's an
 advantage in some ways, but there are so darn MANY different error
 messages that it feels far too centralised and brittle to me.
 >
 >Idris does something in the middle. As I understand David Cristiansen,
 they have an abstract type a bit like `SDoc`, but it is much richer than
 GHC's `SDoc`. They can certainly do colour (and `SDoc`s should too). And
 you can attach auxilary info to the `SDoc` so that when rendered in a web
 browser you get popup hints. This would all be very feasible in GHC, if
 someone did the work.
 >
 >Another big issue is having enough information to hand when you are
 generating the message in the first place. Attaching provenance
 information to type constraints is a huge help (as the Elm article
 suggests) which GHC does, but not well enough. For example Lennart
 Augustsson gave a talk at the Haskell Implementors workshop last year with
 some simple suggestions that work really well in his Mu compiler. Jurriaan
 Hage and his colleages at Utrecht have a lot of experience of this kind of
 thing with Helium. GHC is better placed to do this now than it has ever
 been before, because the type inference engine is increasingly based on
 solving constraints. Almost all type errors are generated in a single
 module, `TcErrors`, if you are interested to look there.
 >
 >I'm keen to make sure that running GHC in batch mode sending output to a
 text file or dumb terminal gives something useful. I don't want to require
 a snazzy IDE or emacs mode. But I'd love to be able to exploit one if it
 was available.

 The proposal I lay out in comment:3 was an attempt to find a way to
 implement the alternative that Simon describes above while minimizing the
 impact of the change.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
Changes (by adamgundry):

 * cc: adamgundry (added)


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by goldfire):

 Replying to [comment:3 bgamari]:
 > Edsko and I were thinking about this a bit in light of the recent
 discussion on Reddit. He had what I thought was a rather nice idea: ...

 I think the idea of embedding richer info into `SDoc` is a good one. In
 particular, I like the idea that this enables a gradual transition. For
 example, we could have some large ADT defined in !TcErrors that represents
 all of the errors that the module produces (but not other modules). Then
 some of the downside of the big-ADT approach that Simon is worried about
 is reduced. And then we could do another module... and so on.

 However, I think indexing `SDoc` is going to lead to trouble. We won't be
 able to have lists of errors that originated in disparate parts of the
 compiler. And we won't be able to embed multiple types of information in
 the same error message. Instead, what if we just use dynamic typing here?
 (gasp!) By this, I mean something like

 {{{
 data Doc = forall a. Typeable a => Embed a
          | Empty
          | ...
 }}}

 When pulling out embedded bits, we just use dynamic checks to get the
 types. Although this seems somewhat un-Haskellish, I think it's forced by
 the very-dynamic nature of an error message. During parsing, a consumer
 can discover what type of embedded information should be at a certain
 spot, and then do the dynamic check. This seems like just the sort of
 thing that dynamic typing excels at.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:9>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by bgamari):

 goldfire, indeed the an ADT-per-compiler-phase is exactly what I was
 thinking (and I have the beginnings of a branch looking at `TcErrors` in
 particular. In my case though, I was thinking of at least starting by
 merely annotating a few semantically-important elements of the message
 (e.g. `Name`s, `Type`s, `TyVar`s, etc.). This would enable, for instance,
 allow links to the definition span of a symbol, printing an expanded
 representation of a type, etc.

 That being said, there is no reason why one couldn't go further with this
 same approach and encode the entire error as a value. This certainly
 offers further advantages, although also implies a bit more work (which is
 why I'm starting with the atoms listed above).

 As far as the indexing issue goes, I was thinking we would give `Doc` a
 `Monad` instance. This would allow a number of quite convenient patterns.
 For instance, have `msgs :: Doc TcErrDoc` containing some errors you'd
 like to print: If you have `pprTcErrDoc :: TcErrDoc -> Doc Void`, you
 could trivially flatten the document with `msgs >>= pprTcErrDoc`.

 Further if you want to combine a `Doc TcErrDoc` with a `Doc ParserErrDoc`,
 you'd simply lift them both into an ADT `data GhcErrDoc = TcErrDoc
 TcErrDoc | ParserErrDoc ParserErrDoc` with `Applicative`. Alternatively,
 if you'd rather keep the universe of error types open, you could opt to
 lift them into a universally quantified `newtype`, roughly like you
 suggest.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by bgamari):

 I should note that adding an index and `Monad` instance to `Doc` isn't
 entirely trivial. I believe it is possible (and have a patch with much of
 the work) but I haven't yet proven to myself that it will preserve the
 invariants that the Hughes pretty-printer expects.

 There are a few implementations of annotated pretty-printers of various
 flavors on Hackage, but they either provide only `Functor` (e.g.
 [[http://hackage.haskell.org/package/pretty-1.1.3.2/docs/Text-PrettyPrint-
 Annotated.html|pretty]], [[http://hackage.haskell.org/package/annotated-
 wl-pprint-0.6.0/docs/Text-PrettyPrint-Annotated-Leijen.html|annotated-wl-
 pprint]]), or are of the Wadler-Leijan variety (e.g.
 [[http://hackage.haskell.org/package/wl-pprint-extras-3.5.0.5/docs/Text-
 PrettyPrint-Free-Internal.html|wl-pprint-extras]]).

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Check out
  * [http://www.itu.dk/people/drc/drafts/error-reflection-submission.pdf
 Reflect on your mistakes] (TFP 14), by [https://www.itu.dk/people/drc/
 David Christansen], in Idris.
  * [http://www.davidchristiansen.dk/2014/09/06/pretty-printing-idris/ A
 pretty printer that says what it means], also David Christiansen

 Any other useful links?

 I'm all in favour of this kind of thinking but it needs careful thinking
 through.

 Simon

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:12>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by bgamari):

 David Christiansen's talk at HIW 2015 is also relevant here,
  - [https://www.youtube.com/watch?v=m7BBCcIDXSg&list
 =PLnqUlCo055hVfNkQHP7z43r10yNo-mc7B&index=10 A pretty printer that says
 what it means (2015 edition)]

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------
Changes (by alanz):

 * cc: alanz (added)


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:14>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
  #8809,#10073,#10179                |
-------------------------------------+-------------------------------------
Changes (by gridaphobe):

 * cc: gridaphobe (added)


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:16>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.9
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
  #8809,#10073,#10179                |
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by mgsloan):

 * cc: mgsloan (added)


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:17>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.9
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
  #8809,#10073,#10179                |
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by niteria):

 * cc: niteria (added)


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:18>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.9
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
  #8809,#10073,#10179                |
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by niteria):

 I've run into this while trying to hack together something like
 http://gcc.godbolt.org/, but for Haskell, with Core, Stg, Cmm and Asm
 output.
 With `-g` all the location data is already nicely tracked all the way to
 Asm and the only piece missing is a way to pretty print with some
 annotations about the ranges.

 I took a stab at adding a parameter to `Doc`, but I haven't gone through
 with it because
 [https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler/main/ErrUtils.hs;eb6b7094c80fda5cc7c1d1ed3386486996f24bff$75-132
 some other types] use it transitively and I couldn't decide between `SDoc
 a` and `SDoc Void` there.

 [http://hackage.haskell.org/package/pretty-1.1.3.2/docs/Text-PrettyPrint-
 Annotated.html pretty] appears to be the same library GHC uses and as
 pointed out by bgamari already supports annotations. Does anyone know if
 they diverged in functionality/semantics? If not, would it be a useful
 step to migrate GHC's `Doc` to annotated version?

 I think an argument against it is that it doesn't have a `Monad` instance,
 but I don't immediately see the benefit of having it.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:19>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #8809: Prettier error messages?

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.9
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
  #8809,#10073,#10179                |
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by thomie):

 Replying to [comment:19 niteria]:
 > Does anyone know if they diverged in functionality/semantics? If not,
 would it be a useful step to migrate GHC's `Doc` to annotated version?

 In #10735, I made GHC's copy of `pretty` pretty much the same as
 pretty-1.2.0, except GHC's copy uses `FastString` instead of `String`.

 pretty-1.2.1 has 2 more commits, but I didn't apply them because of
 performance worries (`compiler/utils/Pretty.hs` is incredibly performance
 sensitive!), see ticket:10735#comment:23.

 Right after pretty-1.2.1, those annotations were added.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:20>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
1234