How to highlighting subexpressions in dumped core?

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

How to highlighting subexpressions in dumped core?

Joachim Breitner-2
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
  [hidden email]
  http://www.joachim-breitner.de/

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: How to highlighting subexpressions in dumped core?

Haskell - Glasgow-haskell-users mailing list
I'm not keen on adding more Tick complexity -- it's a bit out of hand already, and all transformations must "do the right thing".

AnnExpr adds an annotation at every node.  You could, I guess use that to annotate -- but then you'd need a pretty printer for it so you'd end up with duplication.

Worth looking at #8809 and related tickets

S

| -----Original Message-----
| From: Glasgow-haskell-users [mailto:glasgow-haskell-users-
| [hidden email]] On Behalf Of Joachim Breitner
| Sent: 06 March 2018 15:27
| To: GHC users <[hidden email]>
| Subject: How to highlighting subexpressions in dumped core?
|
| 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
|   [hidden email]
|
| https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.joach
| im-
| breitner.de%2F&data=04%7C01%7Csimonpj%40microsoft.com%7Cd3680548aafa49c82
| 7e708d58376c5e7%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636559468531
| 359492%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTi
| I6Ik1haWwifQ%3D%3D%7C-
| 2&sdata=VodWxNvTtF4Asflj%2FeC7%2FbQy0FExq2zq53hvtWoF98s%3D&reserved=0
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: How to highlighting subexpressions in dumped core?

Joachim Breitner-2
Hi,

Am Mittwoch, den 07.03.2018, 12:14 +0000 schrieb Simon Peyton Jones via
Glasgow-haskell-users:
> I'm not keen on adding more Tick complexity -- it's a bit out of hand
> already, and all transformations must "do the right thing".
>
> AnnExpr adds an annotation at every node.  You could, I guess use
> that to annotate -- but then you'd need a pretty printer for it so
> you'd end up with duplication.
>
> Worth looking at #8809 and related tickets

these are all for CoreExpr, right?

I guess I can just copy the pretty-printer code for my maybe a bit
peculiar needs, it’s not too big. (Although highlights in CoreLint
output would be useful for all of use.)

Thanks for your input,
Joachim
--
Joachim Breitner
  [hidden email]
  http://www.joachim-breitner.de/

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users

signature.asc (849 bytes) Download Attachment