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- | boun...@haskell.org] On Behalf Of Joachim Breitner | Sent: 06 March 2018 15:27 | To: GHC users <email@example.com> | 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 | m...@joachim-breitner.de | | 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 Glasgowfirstname.lastname@example.org http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users