Use Hackage for Documentation and Source links#4746
Open
Saizan wants to merge 4 commits intohaskell:masterfrom
Open
Use Hackage for Documentation and Source links#4746Saizan wants to merge 4 commits intohaskell:masterfrom
Saizan wants to merge 4 commits intohaskell:masterfrom
Conversation
fendor
approved these changes
Nov 17, 2025
Collaborator
fendor
left a comment
There was a problem hiding this comment.
One suggestion and can we add a regression test case, somehow to make sure this doesn't accidentally break?
Otherwise, LGTM :)
3f5aa28 to
4977a57
Compare
Author
|
@fendor I got a bit lost trying to add regression tests, would it look something like the ones in FindDefinitionAndHoverTests ? |
controlled by `linkToHackage` configuration field
vidit-od
requested changes
Mar 5, 2026
| Just foundFile -> T.replace "-" sep $ T.pack foundFile | ||
| pure $! | ||
| mconcat $ | ||
| [ "http://hackage.haskell.org/package/" |
Comment on lines
+110
to
+118
| LinkToHackage -> | ||
| toHackageDocUriText env mod (takeFileName <$> doc) | ||
| LinkToLocal -> | ||
| toFileUriText doc | ||
| src_link = case linkSource of | ||
| LinkToHackage -> | ||
| toHackageSrcUriText env mod (takeFileName <$> src) | ||
| LinkToLocal -> | ||
| toFileUriText src |
Collaborator
There was a problem hiding this comment.
( personal nitpick , this is also fine)
can make these one lines
i.e
LinkToHackage -> toHackageDocUriText env mod (takeFileName <$> doc)
LinkToLocal -> toFileUriText doc
src_link = case linkSource of
LinkToHackage -> toHackageSrcUriText env mod (takeFileName <$> src)
LinkToLocal -> toFileUriText src
Collaborator
|
@Saizan Overall looks good, what you linked is a good pattern to follow, but from what i could see, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is enabled by the new
linkToHackageconfiguration option.This is useful if you don't have local documentation or sources built, or other minor downsides of using local files. The
vscode-haskellprovides similar functionality but by trying to mangle the local file links, which is error prone because the path structure has changed between ghc versions.If local documentation/source exists it gets used as a hint for which module to link to, which generally gives better results in case of re-exports. Otherwise we pick the module where the name is defined, and generate the link using its package name and version.
I am quite unsure if how I wired in the
linkToHackageconfig option is appropriate. But I didn't want to do any refactor without some feedback first.Initially I figured
linkToHackageshould be a plugin config forghcide-hover-and-symbols, but the flag affects theGetDocMaprule which structurally appears to be more part of the core? The first way I wrote it I got import cycles so I backed off.I am happy to have the flag where it is or move it if desired. And in any case I will split it into linkDocToHackage and linkSrcToHackage for flexibility.