Provide cached project-root names combinators (cached!) #4531
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.
Overview
After this change, in most cases we'll now use project-root names, even when you're cd'd into a project sub-namespace. If you're not in a project it'll continue to use your current namespace.
E.g. if you do
unison/base/main data.List> view map
it'll pretty printmap
with the PPE from the root of unison/base/main , which includes all your dependencies, since this is what you wanted anyways :man-shrugging:Using the same PPE during your whole project workflow like this also allows us to cache those names per-project branch rather than re-computing them on every command loop which we do right now 馃槵
Implementation notes
BranchHash -> BranchNames
cache which can be used by the CLI and the LSP to avoid re-computing the names for a given branch all the time.projectRootNames[WithoutTransitiveLibs]
,projectRootPPED[WithoutTransitiveLibs]
, and uses these as the defaultbasicNames
helper.Interesting/controversial decisions
Might be a few gotchas to sort out (like there always is when we switch our PPE behaviour), but I think it's worth moving towards this mode.
Test coverage
Existing transcripts mostly cover this, but I'll add one to prove we use the project-root ppe even when in a sub-namespace.
Loose ends
Some open questions would be what to do when the user specifically requests something outside of your project (e.g.
view .blah.foo
) and which PPE to use if the user cd's into a lib dependency, but I think we can find good answers for those.