-
Notifications
You must be signed in to change notification settings - Fork 57
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
Support go to definition for the standard library #1592
Merged
Merged
Conversation
This file contains 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
7e835d0
to
67ca7df
Compare
ParserParams is only used to record the root of the project, which is used to prefix source file paths. However source file paths are always absolute so this is not required.
The Files effect is not responsible for resolving a relative module path into an absolute path on disk. This will allow us to resolve relative module paths to alternative paths, for example to point to the standard library on disk.
library This means that the standard library can exist on disk at a different location to the Juvix project. A command line flag --stdlib-path can be specified to point to a standard library, otherwise the embedded standard library is written to disk at $PROJ_DIR/.juvix-build/stdlib and this is used instead.
652d224
to
c69410f
Compare
janmasrovira
approved these changes
Oct 19, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇
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.
The fundamental change in this PR is that the standard library is now read from disk instead of being read from an in memory representation.
When the compiler pipeline is run, the standard library that is embedded in the juvix binary is written to
.juvix-build/stdlib
in the Juvix project. When the standard library is used, it is read from this location.Implementation
topModulePathToFilePath'
now obtains the absolute path of a top module from theFiles
effect instead of constructing the path using the root directory of the Juvix project. TheFiles
effect knows which modules are in the standard library and so can return the relevant path to the caller.juvix/src/Juvix/Compiler/Concrete/Data/Name.hs
Line 105 in 67ca7df
Loc
constructionThe
mkLoc
function used to have the root path of the Juvix project passed in to construct the location file path from the megaparsecSourcePosition
. However thesourceName
field of theSourcePosition
is already absolute, so the path construction was no-op and could be removed.https://github.com/anoma/juvix/pull/1592/files#diff-407b13d649a9b0e8da32f30d91394ce87893373b6b9c3db4bcd76c58897fc14dR40
Updating
.juvix-build/stdlib
.juvix-build/stdlib
is recreated whenever the versionTag (version + commit hash) of the Juvix binary changes. The current version of the standard library is stored in a file.juvix-build/stdlib/.version
.Using a custom stdlib
Instead of using the pre-bundled standard library you can specify
--stdlib-path PATH
on the CLI to use an existing checkout of the standard library instead.The custom stdlib flag can also be set as an emacs Juvix-mode customisation variable
juvix-stdlib-path
New dependencies
Both path and path-io dependencies are added to implement the
getFilesRecursive
function:juvix/src/Juvix/Prelude/Base.hs
Line 340 in 67ca7df
I'm not 100% certain but I think the only new transitive dependency this adds is dlist.
Closes #1470