-
Notifications
You must be signed in to change notification settings - Fork 704
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
Cabal solver shall consider *-extensions
#2644
Comments
Is the problem that extensions can be conditionally enabled by flags? Otherwise this could be implemented by just not considering such packages in the first place. |
@23Skidoo yeah, that's exactly why this can't be implemented as a trivial pre-filtering step... |
Yes, interesting suggestion. So this isn't quite as easy as it sounds, because the solver uses its own simplified index format right now, and discards the extensions information during an initial conversion step. So the implementation of this would have to extend the solver-specific index format with extension information. Then we'd need a mapping from GHC versions to supported extensions. Is this available somewhere already? Can one query GHC for this easily? Once we have the supported extensions available as an input to the solver, and the extended index info mentioned above, the actual filtering should be very easy. |
@kosmikus afaik, Cabal knows which language extensions a compiler provides, see |
PS: Here's the cabal/Cabal/Distribution/Simple/Configure.hs Lines 568 to 583 in d860aee
|
Ok great. Then this part is easy. So I think this makes this a relatively easy (but not quite trivial), to work on for someone who wanted to gain a little bit of understanding on how the solver works. |
Yes, I think ultimately the solver should be extended to cover several other kinds of dependency in addition to libraries: build tools, language extensions, C libs etc. For language extensions we need to know which extensions are supported by the current compiler, which we already have infrastructure for. So then once the solver is extended to accept the set of supported extensions then it's easy to plug together. The main challenge is extending the solver to cope with multiple different kinds of dependency. For some, like build-tools they're very similar to build libs in that there is something you can install to satisfy the dependency. With language extensions (and there's some others in this category) we can treat them as fixed and so there's nothing you can install to satisfy them. This makes them a bit simpler. |
Yes, let's not make this ticket more complicated than it is. For language extensions, it's a simple yes/no check, which makes this a rather low hanging fruit. |
I'm working on this now. |
Should we formulate some guidelines for |
@phadej fwiw, |
This emulates what GHC>=8 will do on its own for older GHC versions. This is particularly useful in combination with haskell#2644 allowing the solver to toggle flags depending on the availability of `-XTemplateHaskell`. For instance, cross-compilers and/or unregisterised GHC builds often don't have TemplateHaskell support. Having support for toggling flags based on availability of `-XTemplateHaskell` allows `cabal` to support such environments with less manual intervention.
`-XTemplateHaskell` requires GHCi; don't show it in `--supported-extensions` if it's not supported. Together with haskell/cabal#2644 this allows to finally fix a long-standing annoyance in cabal of not being able to detect availability of TH in build-plans. Fixes #11102 See also haskell/cabal#2930 which provides emulation of this feature for older GHCs. Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1484
Fixed by #2873. |
I thought I had seen this feature request filed ages ago, but couldn't find it (the closest related side-comment I did find was #335 (comment)). In any case, here it is (again) explicitly:
It's possible (and afaik recommended) to list used language extensions in the
.cabal
file. However, that information is currently used too late, after the cabal solver has already locked into an install-plan.Instead, the Cabal solver should regard the declared
{default,other}-extensions
as a dependency, and integrate that information with the solving algorithm, thereby allowing to backtrack to other package-versions/install-plans if the current compiler is known not to provide the requested language extensions/cc @dcoutts
The text was updated successfully, but these errors were encountered: