You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
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.
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.
Should we formulate some guidelines for default-extensions and other-extensions fields. As they are soon used by solver. E.g. I use DefaultSignatures but the usage is often guarded by cpp, should I put it in other-extensions or not?
@phadej fwiw, other-extensions and default-extensions are already used right now, it's just that they're checked too late (after the solver ran) by Cabal. However, there's a ticket #1517 about documenting {other,default}-extensions. I usually mirror the CPP-conditional which guards language pragmas inside the .cabal file via Cabal conditionals.
Activity
23Skidoo commentedon Jun 5, 2015
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.
hvr commentedon Jun 5, 2015
@23Skidoo yeah, that's exactly why this can't be implemented as a trivial pre-filtering step...
kosmikus commentedon Jun 5, 2015
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.
hvr commentedon Jun 5, 2015
@kosmikus afaik, Cabal knows which language extensions a compiler provides, see
CompilerInfoAPI at http://hackage.haskell.org/package/Cabal-1.22.3.0/docs/Distribution-Compiler.html and http://hackage.haskell.org/package/Cabal-1.22.3.0/docs/Distribution-Simple-Compiler.htmlhvr commentedon Jun 5, 2015
PS: Here's the
cabal configurecheck against the required*-language:and*-extensionsspecificationsCabalperforms currently (after cabal solving):cabal/Cabal/Distribution/Simple/Configure.hs
Lines 568 to 583 in d860aee
kosmikus commentedon Jun 5, 2015
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.
dcoutts commentedon Jun 5, 2015
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.
kosmikus commentedon Jun 5, 2015
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.
kosmikus commentedon Jul 24, 2015
I'm working on this now.
phadej commentedon Sep 10, 2015
Should we formulate some guidelines for
default-extensionsandother-extensionsfields. As they are soon used by solver. E.g. I useDefaultSignaturesbut the usage is often guarded by cpp, should I put it inother-extensionsor not?hvr commentedon Sep 10, 2015
@phadej fwiw,
other-extensionsanddefault-extensionsare already used right now, it's just that they're checked too late (after the solver ran) by Cabal. However, there's a ticket #1517 about documenting{other,default}-extensions. I usually mirror theCPP-conditional which guards language pragmas inside the.cabalfile via Cabal conditionals.Conditionally omit `TemplateHaskell` from set of supported extensions
DynFlags: Don't list TemplateHaskell as supported if it's not
23Skidoo commentedon Nov 27, 2015
Fixed by #2873.