-
-
Notifications
You must be signed in to change notification settings - Fork 372
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
Streamline getDocumentationTryGhc #2539
base: master
Are you sure you want to change the base?
Streamline getDocumentationTryGhc #2539
Conversation
cff7a10
to
4b91cdf
Compare
This function was "inspired" from GHC code of `getDocs`. Since `getDocsBatch` is not really used for batch - only for singleton elements, lets make 1 element processing function & use it.
`getDocsBatch` cuurently (& before) used only for single name retrieval function. Use of it is in `Documentation` module `getDocumentationTryGhc` where it wraps arg into singleton & gives to `getDocsBatch` & then recieves a Map with 1 entry & unsafely "lookups" doc in it. This work is to supply the proper single name retrieval-optimized version to stop that `getDocsBatch` there. & further ideally `getDocumentationTryGhc` uses single-retrieval & `getDocumentationsTryGhc` uses a batch mode & batch mode gets optimized along the lines of: haskell#2371
9011ae8
to
c68f9be
Compare
a7a00ac
to
cda18cc
Compare
cda18cc
to
68ebfdf
Compare
5451a2a
to
0a87017
Compare
Overall, I'd liked to keep explicit return types of Having exceptions explicitly in the types also allowed to figure out how to do rebasing onto GHC 9.2 changes & the API changes of GHC. Having After current changes are figured-out, code may return to trow/catching the exceptions, but I'd highly preferred to have |
The main agenda there is to provide argument documentation in a form that is neat for further processing. As to provide the documentation as maps from the name to documentation. Which would allow to properly shipping the function argument show work.
During that, improving on
getDocumentation{,s}TryGhc
code paths:Introducing
initTypecheckEnv
to abstract type checking environment initialization between several modes. (It abstracts code that is currently in mainline, further improvements there seem to be possible but they are not the scope of this PR, but are considered future changes).Introducing the
getDocsNonInteractive'
, a function that was used/requested in the source code but not abstracted - a function that is analog to GHCsgetDocs
but modifies it to work in the non-interactive form. Gets used as an abstraction to open module interfaces to retrieve documentation.Introducing
getDocsNonInteractive
- a function to get the documentation about aName
from a module interface.Updating
getDocsBatch
- to share abstractions withgetDocsNonInteractive
. These updates also make available possibilities of further optimizations as in getDocsBatch for bulk processing #2371.getDocumentationTryGhc
(single):getDocsNonInteractive
), and as so - no longer depends ongetDocumentationsTryGhc
(plural).getDocumentationsTryGhc
(plural) -getDocumentationTryGhc
(single) no longer needs to pretend element is a singleton to send it togetDocumentationsTryGhc
(plural) to retrieve ahead
getDocumentationsTryGhc
(plural):No longer used. The current patch just shows that this code path is not used in reality, actively doing that also allows working on the batch retrieval if it is found beneficial.
Instead of
IO [SpanDoc]
(& matchingName
s on[]
indexes) - returns properMap Name SpanDoc
type.There was use of Lazy
Map
in the code, which seemed to imply use/process all elements, considered it is enough obvious to ensure those are Strict Maps, that is a minor thing and can roll it back upon request.This PR is a part of the effort to provision argument documentation into UI. All mentioned above functions are used to pass the argument documentation further into the code. GHC 9.2 started to ship arg docs in the form of the
IntMap
, which this PR also migrated to. Current changes to functions are seen as an improvement already & further PRs would work on argument documentation provisioning further.