New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit reference to instance method instead class method #73
Comments
Mental note. From Simon:
Interesting. Could for start just point to the "outermost" instance (here Eq [a]), but ideally (if the callsite's tc dict is fully saturated) we could even generate a virtual, monomorphic linked source (where clicking class methods used in the outermost instance's implementation links to the dependent instance's.....). But that seems deep. Alternatively, following a link to a (virtual / overloadded / classmethod ....) thing should take into account the "current stack" or "current context", and that would have to be rolled along. |
+@mpickering for insights. |
Note: this might come to HIE, see https://gitlab.haskell.org/ghc/ghc/merge_requests/1286 as mentioned in https://gitlab.haskell.org/ghc/ghc/wikis/hie-files:
It seems to be around https://gitlab.haskell.org/ghc/ghc/merge_requests/1286/diffs#7f924eb82ea52b493e50fc467c301adb6a0eaf32_419_517 . The existing feature
seems to capture the monomorphized type, but not the instance used to get it? Not sure. |
When the instance is fully resolved.
Basic plan (probably doesn't handle edge cases etc):
HsVar
'sid
'sidDetails
isClassOpId
(alsoisClassOpId_maybe
)classTyCon
from theClass
of theClassOpId
HsWrap
wrapping theHsVar
containsWpEvApp (EvId x)
, wherex
's type is of formTyConApp <the classTyCon> ...
x
is thedFunId
... but how do we go from that (knowing theClass
and the method name) to the instance method var?Idea: get the module of the
dFunId
name usingnameModule
, thenGHC.getModuleInfo
on it. Then we can lookup theClsInst
list in that module... but it doesn't refer the actual members, just theDFunId
, again. Ok, not the best idea. Can we take thatDFunId
apart?Idea#2: assign Tick to instance methods by concatenating the DFunId tick with the method name, so it's trivial to construct the Tick reference from the locally available info. Sounds like a much better idea.
This can work - but the instance method decls need to be taken from the typechecked tree, where we can harvest the related dFunId (the
abe_mono
is easier to find theclassTyCon
, since there's no context) by looking at which $c... gets applied in the $d... binding.The text was updated successfully, but these errors were encountered: