-
Notifications
You must be signed in to change notification settings - Fork 132
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
Automatically figure out dependencies for the project #165
Comments
In order for this to work without having to download all the packages in the package set your project is using, you'd also need to add metadata to a package-set file which contains the mapping from That metadata would need to be rebuilt whenever you merge a PR into the packageset. |
@kritzcreek good points. Some ideas and questions:
|
Your override/addition would need to change the package -> module mapping accordingly, or spago would need to make sure all additions and overrides are present and regenerate the mapping information for those locally. I think ideally the metadata generator lives in a different binary than spago though, so we can avoid the large dependency footprint.
That would only be true if we required that every import statement mentions the package it's importing from. I think it's very unlikely that we can require that as it would break every PS file in existence. That's going to need a fair amount of thought still (it might be possible to require it if we can provide an automatic migration tool) |
@kritzcreek I just realized that |
Update: purescript-nix generates the aforementioned metadata file by implementing a small parser for imports. Since the imports syntax is not going to change dramatically anytime soon, maybe this is a viable approach.. |
There were questions on Slack from @reactormonk:
With the current idea
The problem would be that you’d have to include the whole of the package set in the
If spago (or the compiler) would generate a metadata file from the package set with the mapping “module → package” (and/or “definition → modules”) then we’d know which dependencies we have from the files. |
@jmackie has proposed a new |
@hdgarrood I would say so, yes! E.g. this is what you get for the "Main": {
"path": "src/Main.purs",
"depends": [
"Prelude",
"Control.Applicative",
"Control.Apply",
"Data.Functor",
"Data.Function",
"Control.Category",
"Control.Semigroupoid",
"Data.Boolean",
"Data.Ord",
"Data.Eq",
"Data.HeytingAlgebra",
"Data.Symbol",
"Data.Unit",
"Data.Show",
"Record.Unsafe",
"Type.Data.RowList",
"Type.Data.Row",
"Data.Void",
"Data.Ord.Unsafe",
"Data.Ordering",
"Data.Semigroup",
"Data.Ring",
"Data.Semiring",
"Control.Bind",
"Control.Monad",
"Data.BooleanAlgebra",
"Data.Bounded",
"Data.CommutativeRing",
"Data.DivisionRing",
"Data.EuclideanRing",
"Data.Field",
"Data.Monoid",
"Data.NaturalTransformation",
"Effect",
"Effect.Console"
]
} Then to get the package names one has to lookup for all the other names in the However I'm still about concerned about the UX implications of all of this (see my previous comment), but maybe it will be fine (e.g. it would work so that to add a dependency one would have to import a module from that package and restart |
An alternate to removing Some benefits to this approach:
I'm not pushing for this approach, but wanted to throw it out there in case it was appealing. |
@joneshf thanks for bringing this up! I did consider this kind of approach before (as this is what you do with Cabal too), and I think that:
|
No worries. As mentioned, I'm not trying to push these changes on you.
Oh, that's the two places? I thought we were talking about
Doesn't this get harder? You have to parse every module in the source tree, then download and parse every package in the package set to find which package contains the modules, then you can audit the dependencies. |
Oh that's right, that would add an additional step because you still need to compute somewhere the map |
after looking at this issue, it appears to be blocked waiting for the graph command, subsequently #415 is blocked as well |
Now that we shipped a build-time check for "packages you should have in your project" (in #730), and given that we'll soon change the config format to be able to support version ranges, I don't think this is viable anymore - I'll close. |
Currently when one adds a package to the
packages.dhall
the expectation is that spago will also pick it up as a dependency...but no, build dependencies need to be specified in thespago.dhall
, as thepackages.dhall
only contains the pool of available packages.I think this is not good UX and the user should not need to specify the dependencies in
spago.dhall
, so the idea here would be to figure out the package names of the dependencies we're using from the import statements in the source files.We can do this because by definition of package set a module name can refer to at most one package.
How to do this: there was an experiment for this in psc-package from @kritzcreek here, calling the compiler to parse the files, get out the import statements, and figuring out the packages from there.
If we're able to do this reliably then we could:
dependencies
key in thespago.dhall
The text was updated successfully, but these errors were encountered: