Open Kleidukos opened 1 month ago
I'm not sure that with-compiler
is necessarily a good mechanism for this. It takes a binary name, not any symbolic constraint that ensures you get a compiler with that version. This breaks e.g. on many distributions you just get ghc
, no version prefix. So a project which assumes you get version-suffixed compilers will break on other machines.
We have impl(ghc)
which actually checks the GHC version. It would be nice if we had more ways of interacting with that.
Also note that this is really a problem for packages. Doing this with with-compiler
doesn't save you the moment you depend on a package that doesn't support your GHC. See e.g https://github.com/haskell/cabal/issues/9648
You're indeed right, it's certainly my bias as a user of ghcup
. :)
We have
impl(ghc)
which actually checks the GHC version. It would be nice if we had more ways of interacting with that.
Do we have something like Stack's user-message so that we could message the user?
if !(impl(ghc >= x.y.z) && impl(ghc < m))
user-message: Can't find the expected compiler
@philderbeast we don't but it's discussed in https://github.com/haskell/cabal/issues/9648
Context
After spending some time in the contact of beginners, a recurring thing has been noted: The GHC version is indirectly constrained by the bounds on the
base
library.This is not a very common behaviour in other ecosystems, and each time I explain how this works, I feel like I am just describing a very weird and counter-intuitive situation instead of giving an actual good reason.
From a personal standpoint I also systematically write down:
in my new executable projects.
Compare the difference in user experience:
When exclusively relying on base bounds
When using
with-compiler
Moreover, with the error codes, we are able to provide better feedback to the user regarding the reason
cabal
fails. Even this infamous search engine gives relevant results:This RFC
The point of this RFC is to argue in favour of changing the behaviour of
cabal init
in two ways:cabal.project
where thewith-compiler
stanza is set to the current GHCghc-xxx
string, with the current GHC's version as a default.We can even add a link to the project file documentation as a comment in the first line.
The whole point is to improve a beginner's first steps in Haskell. Cloning a repository and getting a solver error when running
cabal build
is not people particularly enjoy, especially when they have to go on a wild goose chase to figure out which version ofbase
is shipped with which version ofghc
.Should this RFC be accepted, I will implement it.