[GHC] #8809: Prettier error messages?

GHC ghc-devs at haskell.org
Fri Jul 3 08:59:56 UTC 2015


#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


More information about the ghc-tickets mailing list