-
Notifications
You must be signed in to change notification settings - Fork 235
WIP Annot backend #708
WIP Annot backend #708
Conversation
| -- nor NameSet because these are blank after type checking. | ||
| skipGuards :: [TypeRep] | ||
| skipGuards = [ typeRep (Proxy :: Proxy NameSet) | ||
| , typeRep (Proxy :: Proxy (PostTc Id Kind))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not totally sure if this is still necessary - I saw no ill effect from turning these off. The rationale behind them is in Tamar's 2011 blog post linked above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ok I guess.
| , not (isGeneratedId v) | ||
| ] | ||
|
|
||
| -- | Filter out compiler-generated names like @$trModule@ or @$cmappend@. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's a better way to do this, I'd love to know about it! The IdDetails are completely blank for all IDs by the time it gets here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is ugly but I am not sure there are other ways to check if an Id is compiler generated.
| getNames src z = [(unsafePpr x, (x, idLoc src x)) | x <- findIds z] | ||
|
|
||
| renderId :: Id -> String | ||
| renderId = showSDocForUser unsafeGlobalDynFlags neverQualify . pprTyThing showSub . AnId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using unsafeGlobalDynFlags throughout. Since we run after typechecking this seems safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please thread DynFlags through. Relying on global state breaks my reasoning.
|
Thank you for your effort! This sounds definitely interesting! I will have a look later. |
| getNames src z = [(unsafePpr x, (x, idLoc src x)) | x <- findIds z] | ||
|
|
||
| renderId :: Id -> String | ||
| renderId = showSDocForUser unsafeGlobalDynFlags neverQualify . pprTyThing showSub . AnId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please thread DynFlags through. Relying on global state breaks my reasoning.
| -- nor NameSet because these are blank after type checking. | ||
| skipGuards :: [TypeRep] | ||
| skipGuards = [ typeRep (Proxy :: Proxy NameSet) | ||
| , typeRep (Proxy :: Proxy (PostTc Id Kind))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ok I guess.
| , not (isGeneratedId v) | ||
| ] | ||
|
|
||
| -- | Filter out compiler-generated names like @$trModule@ or @$cmappend@. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is ugly but I am not sure there are other ways to check if an Id is compiler generated.
| -- source generation flag). | ||
| , ifaceTokenizedSrc :: !(Maybe [RichToken]) | ||
|
|
||
| , ifaceTcSource :: TypecheckedSource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's signal here that ifaceTcSource is evaluated.
|
FWIW, if the generation of the |
|
Awesome! Sorry I let this languish, I was busy moving job and country. Will revive the PR this weekend. |
|
This PR was closed accidentally, see this comment for how to reopen. |

This is an attempt to revive the Annot backend. This backend serialises type checking information into a textual format that looks as follows:
This file format is then consumed by HsColour to add type annotations to highlighted source code. These type annotations appear when moused over. An example can be seen here.
This work was largely done by Ranjit Jhala in 2013. It was fully merged into HsColour, but stalled on the way into Haddock because of an unwanted
sybdependency. Nowadays we have copied large swaths of SYB into Haddock, so integrating this work is easy enough.While I would rather see this work reimplemented as part of the fancy new hyperlinked backend, I feel the fact that HsColour already supports this format makes completing this backend worthwhile.