How to highlighting subexpressions in dumped core?

Joachim Breitner mail at joachim-breitner.de
Tue Mar 6 15:26:57 UTC 2018


Hi,

one of my plugins dumps core output to the user, and this core output
contains “interesting subexpressions”. I would like to highlight them
(for example, with `bold :: SDoc -> SDoc`).

As far as I can see, I have these options:

 * I copy all, or most of PprCore, and extend ppr_expr to look for the
   subexpressions that I care about.

   Obviously not nice, because of a code copy.

 * I extend GHC to support that. One way would be to add a new 
   constructor to `data Tickish id = … | Highlight` so that
   I can wrap the interesting subexpressions in
   `Tick Highlight e`.

   That’s a bit better, and could even be useful in GHC (e.g. a linter
   error could highlight the lint error location), but it’d mean
   waiting for new compiler versions until I can make use of that,
   and it is still limited to subexpressions – highlighting a binder
   would require yet another support.

 * Could we extend SDoc with an operation

      highlightIn :: SDoc -> SDoc -> SDoc

   or

      highlightIn :: Doc -> Doc -> Doc

   where `highlightIn doc1 doc2` is like doc2, but any subdocument that
   is “ismorphic to doc1” (for whatever that means) gets highlighted?


Are there other options that I might not see right now?



Cheers,
Joachim   

-- 
Joachim Breitner
  mail at joachim-breitner.de
  http://www.joachim-breitner.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://mail.haskell.org/pipermail/glasgow-haskell-users/attachments/20180306/46c17b63/attachment.sig>


More information about the Glasgow-haskell-users mailing list