google / google/haskell-indexer
Emit reference to instance method instead class method
- Dominant language
- Haskell
- Stars
- 103
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
When the instance is fully resolved.
Basic plan (probably doesn't handle edge cases etc):
- see if `HsVar`'s `id`'s `idDetails` is `ClassOpId` (also `isClassOpId_maybe`)
- if so, get the `classTyCon` from the `Class` of the `ClassOpId`
- look if the `HsWrap` wrapping the `HsVar` contains `WpEvApp (EvId x)`, where `x`'s type is of form `TyConApp ...`
- if we found it, then `x` is the `dFunId`... but how do we go from that (knowing the `Class` and the method name) to the instance method var?
Idea: get the module of the `dFunId` name using `nameModule`, then `GHC.getModuleInfo` on it. Then we can lookup the `ClsInst` list in that module... but it doesn't refer the actual members, just the `DFunId`, again. Ok, not the best idea. Can we take that `DFunId` 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 the `classTyCon`, since there's no context) by looking at which $c... gets applied in the $d... binding.
Contributor guide
Assessment
This issue has not been assessed yet.