Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide cached project-root names combinators (cached!) #4531

Draft
wants to merge 6 commits into
base: trunk
Choose a base branch
from

Conversation

ChrisPenner
Copy link
Contributor

@ChrisPenner ChrisPenner commented Dec 19, 2023

Overview

  • Starts the move to using Names and PPEs at the project scope
  • Removes global fallbacks for these PPEs, which may lead to hashes if a project isn't properly self-contained, but also avoids huge delays and weird name suffix-qualification from loading names from who-knows-where.
  • Makes it much easier to get the names/ppe you actually want (e.g. the project root names with or without transitive libs)
  • Caches names/ppes by branch hash to avoid re-computing huge names objects on every command invocation. Can cache up to 4 project-branches at a time currently to avoid thrashing.

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 print map 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

  • Adds a GLOBAL 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.
  • Provides new combinators for getting project names and PPEs, see projectRootNames[WithoutTransitiveLibs], projectRootPPED[WithoutTransitiveLibs], and uses these as the default basicNames 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.

@ChrisPenner ChrisPenner changed the title Use Project Root names rather than current-path names (and cache them!) Provide cached project-root names combinators (cached!) Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant