-
Notifications
You must be signed in to change notification settings - Fork 81
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 reexporting modules #357
Comments
I've started hacking at this (PR shortly hopefully). Basics are there but current set of compromises/challenges is:
|
OK I think I've got this working. However, in doing so I've made some design decisions that I think it might be worth discussing here before I open some PRs (not sure who other than @mboes I should tag). The thing that generally underpins all of these is the problems created by packages that come pre-installed with GHC:
If we were to accept this design choice, we'd have to (I think) add a similar sort of
Hope this makes sense, grateful for any feedback. Proof of concept of the changes ( |
The proposed change to Hazel SGTM; as you said, we can get that information automatically and it simplifies the internals of rules_haskell. I'm less convinced that choice 3 is necessary. It looks like |
Thanks for the feedback! If I understand correctly, you're saying we could implement 1 and 2 and then for 3, rather than constructing something like:
where
with the implicit |
I suspect @regnat will object to |
Happy to discuss alternatives on mandatory versions. On @judah's point about global DB; on hacking/reading the document it seems that appending a separator ( |
Thinking about this, we could make |
I'd say try the simplest thing first and then we can iterate, if we really don't want mandatory versions. |
I'm in favour of merging Hazel. @judah what do you think? |
Merging Hazel into rules_haskell sounds good to us. A couple of up-front requests I would have around the merge are: (1) if possible, to preserve the history with I probably won't have time to actually do that merge in the near future, but could help advise if someone else wanted to take it on. |
I suspect @regnat <https://github.com/regnat> will object to
|mandatory = True| for a version field in |haskell_import|.
I'd rather have it optional since − at least for now − that's a
redundant information, but having it mandatory isn't a big issue for me.
In the nixpkgs use-case, we would probably want to generate the
`haskell_import` rules anyway, so adding the version doesn't cost much
|
So it turns out that the |
OK, after a bit of research I think the following plan makes sense:
Appreciate there's a lot of change in here; keen for feedback @mboes @judah and any others. |
rules_haskell supports two use cases at the moment:
@lunaris the reason we support (1) is because it's so low-tech. When rules_haskell started, we could use it in production without first working our way up to full Hazel. Now that Hazel works great, the Nixpkgs route is still a nice backup to have, and for some setups might be a better fit. That said, the future for most people is probably Hazel. So my view is that (1) is nice to have, but if it gets in the way of progress significantly then we'd be okay with dropping it. At first, it sounded to me like this ticket was blocked in a big way by the Nixpkgs use case. Thus potentially warranting us dropping it now. But it turns out that at least for this ticket, there's another workaround. It turns out that GHC is perfectly happy having only package names in the package configuration files in the package db. It's Meanwhile, we can work around this upstream bug by not using I'll push a PR later today with small modifications to your #381 that make it all work. |
Fixed in #385. |
So unfortunately I think the change to using
I'm not quite sure what is up because tweaking the command being run (from passing |
In #385, we claimed to exploit the fact that GHC only needs package names in reexport declarations to obviate the need for knowing the versions (and dependency hashes) of all prebuilt packages. We provided a test to substantiate this indeed works. But it turns that the test was not a good test. The test was flawed because it featured libraries reexporting `base`. It turns out that `base` (along with `rts`) are magical in GHC. Because they are so-called "wired-in packages", they are assumed unique and are therefore not located using a version number. So while the scheme in #385 worked for `base`, it didn't work in the general case, as observed by @lunaris. The fix consists qualifying all package reexports with full package id's, not package names. How do we derive a package id given only a package name? The solution is to have the toolchain generate a dump of the global package database that ships with the compiler. This is only needed once for the entire workspace. From this dump, we can lookup the full package id given any particular name. Fixes #357.
In #385, we claimed to exploit the fact that GHC only needs package names in reexport declarations to obviate the need for knowing the versions (and dependency hashes) of all prebuilt packages. We provided a test to substantiate this indeed works. But it turns that the test was not a good test. The test was flawed because it featured libraries reexporting `base`. It turns out that `base` (along with `rts`) are magical in GHC. Because they are so-called "wired-in packages", they are assumed unique and are therefore not located using a version number. So while the scheme in #385 worked for `base`, it didn't work in the general case, as observed by @lunaris. The fix consists qualifying all package reexports with full package id's, not package names. How do we derive a package id given only a package name? The solution is to have the toolchain generate a dump of the global package database that ships with the compiler. This is only needed once for the entire workspace. From this dump, we can lookup the full package id given any particular name. Fixes #357.
In #385, we claimed to exploit the fact that GHC only needs package names in reexport declarations to obviate the need for knowing the versions (and dependency hashes) of all prebuilt packages. We provided a test to substantiate this indeed works. But it turns that the test was not a good test. The test was flawed because it featured libraries reexporting `base`. It turns out that `base` (along with `rts`) are magical in GHC. Because they are so-called "wired-in packages", they are assumed unique and are therefore not located using a version number. So while the scheme in #385 worked for `base`, it didn't work in the general case, as observed by @lunaris. The fix consists qualifying all package reexports with full package id's, not package names. How do we derive a package id given only a package name? The solution is to have the toolchain generate a dump of the global package database that ships with the compiler. This is only needed once for the entire workspace. From this dump, we can lookup the full package id given any particular name. Fixes #357.
In #385, we claimed to exploit the fact that GHC only needs package names in reexport declarations to obviate the need for knowing the versions (and dependency hashes) of all prebuilt packages. We provided a test to substantiate this indeed works. But it turns that the test was not a good test. The test was flawed because it featured libraries reexporting `base`. It turns out that `base` (along with `rts`) are magical in GHC. Because they are so-called "wired-in packages", they are assumed unique and are therefore not located using a version number. So while the scheme in #385 worked for `base`, it didn't work in the general case, as observed by @lunaris. The fix consists qualifying all package reexports with full package id's, not package names. How do we derive a package id given only a package name? The solution is to have the toolchain generate a dump of the global package database that ships with the compiler. This is only needed once for the entire workspace. From this dump, we can lookup the full package id given any particular name. Fixes #357.
GHC supports reexporting modules from upstream dependencies, since 7.10.3. See https://www.haskell.org/cabal/users-guide/developing-packages.html#pkg-field-library-reexported-modules. This will be useful for Backpack support. We could implement this with an API like the following:
I propose the
exports
attribute name to be consistent with the Java rules. The syntax inside the strings is the same as Cabal and GHC.The text was updated successfully, but these errors were encountered: