Cabal and HLS should coordinate the `cabal-version` generated by `cabal init`
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the feature request**
HLS is about to add support for `.cabal` files, displaying errors and warnings, offering completions, etc...
The `.cabal` file generated by `cabal init` has the latest available `cabal-version`.
For example:
```sh
> mkdir example
> cd example
> cabal-3.12.1.0 init -n --lib
> head -n 1 example.cabal
cabal-version: 3.12
```
This poses a problem for HLS, as HLS depends on ghc, we have to use the `Cabal` version linked against the ghc version the HLS binary supports. This means that the `cabal-version` produced by `cabal init` is by default virtually always newer than what any HLS version supports.
This leads to an ugly error message and most features not working in the `hls-cabal-plugin` :

My suggestion, after talking to @Kleidukos, is to coordinate the default `cabal-version` produced by `cabal init` with the support window of HLS. ~~As the HLS-2.9.0.1 release supports GHC 9.4 - 9.10, we consequentially need the default `cabal-version` to be `3.6` (assuming, ghc-9.4 is linked against Cabal-3.6) for a better UX.~~
EDIT: incorrect assumption of mine.
HLS 2.9.0.1 ships with `Cabal-3.10`, so `cabal-version: 3.8` would work for us.
**Additional context**
HLS issue: https://github.com/haskell/haskell-language-server/issues/4401
The issue is softened once private dependencies allow us to depend on a newer, private Cabal version for the cabal plugin: https://github.com/haskell/cabal/pull/9743
Contributor guide
Research direction
Start at the `cabal init` entry point and review the HLS issue and private-dependency context linked in the report. Determine the supported Cabal window and where the generated `cabal-version` is selected; done means new projects use a version compatible with HLS while preserving valid Cabal initialization.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100