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 would love to switch away from stack for development, but there are some real and important things missing to do so.
In this issue I'd like to list those with checkboxes, in case feature-parity with stack is something the cabal team would want to achieve:
cabal test all --no-rerun-tests: Don't rerun test suites that have already passed.
cabal build all --file-watch: File watching. This is arguably not cabal's responsibility because you can do something close-enough with feedback for example, but cabal is haskell-build-process-aware and could do better than feedback can.
Reacted by IC Rainbow, Tom Sydney Kerckhove, Daniel P. Brice, Marijan Petričević, Tom Ellis, Jaro, Ondřej Súkup, Mikolaj Konarski, Santiago Weight, Dennis Gosnell and 15 more
Although I have switched from Stack to Cabal for development, I agree with this list and would like to see these things implemented. I think there are existing issues for some of them:
Loading multiple packages in cabal repl a la stack repl would also be nice.
A thing that I get mileage out of with Stack is (1) specifying a Stackage snapshot in one line (rather than a big lock file), and (2) the fact that I can then cherry-pick and pin individual package versions down to the SHA hash. This experience is quite different to the big lock file specifying all dep versions, and the hash pinning allows you to not trust the package server.
Personally, I think GHC management is a big deal. But it's worth noting that the Haskell community is split into those who use Nix and those who don't. So it's common for a lot of Cabal-using devs to defer certain features (such as package pinning or GHC management) to their Nix configuration, similar to using entr/watchexec instead of --file-watch, but that leaves the other half of the community preferring to stick with Stack!
(Although maybe like @tfausak some people just ignore the few missing features and use Cabal.)
Regarding docs
I'd eagerly read some kind of "cabal for stack enthusiasts" article which explains how to achieve all the things you're used to with stack from a proper stack user's perspective (not a cabal user who's vaguely aware of what stack can do or used it a little bit).
Contributing
I'm afraid I can't contribute any work towards this. I've done my time on Haskell tooling. 😂 Around 2015, I wrote the first commit on Stack and shaped some of its direction, alongside Michael Snoyman, Michael Sloan, Emanuel Borsboom. Tooling is Hard, especially Haskell as it's a moving target. The best outcome would be that the community converges again on one build tool. But it's taken years to get to this point and may take some more years yet!
Reacted by Ashley Yakeley, Mikolaj Konarski, Dennis Gosnell, theGhostJW and George Thomas
Reacted by Tom Sydney Kerckhove, David Simmons-Duffin, Michael Sloan, Shayne Fletcher, Dennis Gosnell, Scott Santucci, Simon Michael and Tiago de Paula
I think both automatic hpack execution and auto-expanding Stackage snapshot names to lockfiles are best done via hooks, since they break off nicely into discrete tasks that already have well-known public interfaces. (I admit for hpack specifically I am biased in that I don't like hpack's design decisions and don't want Cabal to endorse it.)
Reacted by daylily, Alexander Makarov, Scott Santucci, Ganesh Sittampalam and George Thomas
I am curious how cabal test all --no-rerun-tests would work specifically? It sounds intriguing and a ticket on it would be welcome, especially coupled with some explanation of the semantics of the existing stack feature.
A ticket for multi-package code coverage would also be welcome.
I think I agree, but I do think it would be nice if cabal could somehow select among the installed GHC versions for a particular project, perhaps by interfacing with ghcup.
I think I agree, but I do think it would be nice if cabal could somehow select among the installed GHC versions for a particular project, perhaps by interfacing with ghcup.
GHC by default includes executables with complete version numbers, cabal supports -w to specify a compiler to use, and this can be stored in cabal.project/cabal.project.local files.
Personally, I have a setup where my "default" ghc is first in path, followed by all other installs. This causes ghc to refer to the first (i.e. my default) ghc executable in my path, while version tagged GHCs are found later on path. This way simply writing cabal build -w ghc-8.10.7 will use the relevant GHC and this can be stored in aforementioned config files too.
All that would be needed to point a project to a specific GHC installed via ghcup would be: cabal configure -w path/to/ghc-version and from then on cabal build will automatically use that one.
Reacted by Jakob Brünker, Koz Ross, Mikolaj Konarski, FTS and Scott Santucci
I am curious how cabal test all --no-rerun-tests would work specifically? It sounds intriguing and a ticket on it would be welcome, especially coupled with some explanation of the semantics of the existing stack feature.
@gbaz Stack keeps track of which test suites have been run since their dependencies have last changed and whether the run was successful (exit code 0, I guess). Then it doesn't rerun the test suite if it's already succeeded and the dependencies haven't changed.
Eh, I disagree on it being a bug. If I choose to disable tests/benchmarks, I want them disabled. We could enable tests and/or benchmarks by default though (didn't we already do that?)
I agree cabal build all not building all by default is a huge UX flaw. @fgaz if you want to disable some of it, you should be able to do so, of course, but this is a separate concern: e.g. if you add tests: False in your config or your project file, then, od course, cabal build all shouldn't build tests. The question here (as you rightly point out) is about the default behavior --- the one that applies when there are no explicit instructions from the user.
And no, we didn't enable tests (#7883) and/or benchmarks by default. The last development on this front, I think, was enabling docs by default when the user calls cabal haddock. That didn't go down well, though: #8725 Doing the same for cabal test led to another mega-thread but in the end, it looked like there was a path forward, and just no one bothered implementing it.
I wonder if the easiest (and reasonable) way to improve that would be to generate the default config with tests: True, benchmarks: True. We can mention in the docs that to avoid building tests/benches for a particular project you can always cabal configure --disable-tests --disable-benchmarks. The downside of this cheap solution would be that even when selecting a particular component (cabal build blah), cabal will try to solve for everything (#4087).
Reacted by Francesco Gazzetta, Tom Sydney Kerckhove, Mouse, George Thomas, Scott Santucci, fendor and Dennis Gosnell
Another (backwards-compat) solution would be to introduce a new target everything that solves and attempts to build literally all targets. This arguably would retroactively justify all's current behavior, analogous to -Wall vs -Weverything.
This arguably would retroactively justify all's current behavior, analogous to -Wall vs -Weverything.
Let's not pretend that's good design. It's atrocious and after 10 years of Haskell I'd fail every interview that asks me what the difference of both GHC flags are.
Reacted by Tom Sydney Kerckhove, George Thomas, Hécate, Tommy Bidne, Sibi Prabakaran, Scott Santucci, Kazutaka Matsuda and fendor
As for the comments in this thread about cabal build all building or not building tests and benchmarks and whether "all" includes those and whether cabal build should be equivalent to cabal build all. All of this is much easier to explore with #9744. Here's an example from this repository (cabal target is the same as cabal target all):
Activity
ulysses4ever commentedon Nov 18, 2022
Would help to have links to respective stack documentation sections.
NorfairKing commentedon Nov 18, 2022
@ulysses4ever Good idea, I added some links.
tfausak commentedon Nov 18, 2022
Although I have switched from Stack to Cabal for development, I agree with this list and would like to see these things implemented. I think there are existing issues for some of them:
cabal watchcommand #5252hpackcurrently has)fgaz commentedon Nov 18, 2022
chrisdone-artificial commentedon Nov 18, 2022
Regarding feature parity
Loading multiple packages in
cabal repla lastack replwould also be nice.A thing that I get mileage out of with Stack is (1) specifying a Stackage snapshot in one line (rather than a big lock file), and (2) the fact that I can then cherry-pick and pin individual package versions down to the SHA hash. This experience is quite different to the big lock file specifying all dep versions, and the hash pinning allows you to not trust the package server.
Personally, I think GHC management is a big deal. But it's worth noting that the Haskell community is split into those who use Nix and those who don't. So it's common for a lot of Cabal-using devs to defer certain features (such as package pinning or GHC management) to their Nix configuration, similar to using
entr/watchexecinstead of--file-watch, but that leaves the other half of the community preferring to stick with Stack!(Although maybe like @tfausak some people just ignore the few missing features and use Cabal.)
Regarding docs
I'd eagerly read some kind of "cabal for stack enthusiasts" article which explains how to achieve all the things you're used to with stack from a proper stack user's perspective (not a cabal user who's vaguely aware of what stack can do or used it a little bit).
Contributing
I'm afraid I can't contribute any work towards this. I've done my time on Haskell tooling. 😂 Around 2015, I wrote the first commit on Stack and shaped some of its direction, alongside Michael Snoyman, Michael Sloan, Emanuel Borsboom. Tooling is Hard, especially Haskell as it's a moving target. The best outcome would be that the community converges again on one build tool. But it's taken years to get to this point and may take some more years yet!
fgaz commentedon Nov 18, 2022
xplat commentedon Nov 18, 2022
I think both automatic hpack execution and auto-expanding Stackage snapshot names to lockfiles are best done via hooks, since they break off nicely into discrete tasks that already have well-known public interfaces. (I admit for hpack specifically I am biased in that I don't like hpack's design decisions and don't want Cabal to endorse it.)
gbaz commentedon Nov 18, 2022
I am curious how
cabal test all --no-rerun-testswould work specifically? It sounds intriguing and a ticket on it would be welcome, especially coupled with some explanation of the semantics of the existing stack feature.A ticket for multi-package code coverage would also be welcome.
JakobBruenker commentedon Nov 18, 2022
I think I agree, but I do think it would be nice if cabal could somehow select among the installed GHC versions for a particular project, perhaps by interfacing with ghcup.
merijn commentedon Nov 18, 2022
GHC by default includes executables with complete version numbers, cabal supports
-wto specify a compiler to use, and this can be stored incabal.project/cabal.project.localfiles.Personally, I have a setup where my "default" ghc is first in path, followed by all other installs. This causes
ghcto refer to the first (i.e. my default)ghcexecutable in my path, while version tagged GHCs are found later on path. This way simply writingcabal build -w ghc-8.10.7will use the relevant GHC and this can be stored in aforementioned config files too.All that would be needed to point a project to a specific GHC installed via ghcup would be:
cabal configure -w path/to/ghc-versionand from then oncabal buildwill automatically use that one.JakobBruenker commentedon Nov 18, 2022
@merijn that is good to know, thank you
NorfairKing commentedon Nov 19, 2022
@gbaz Stack keeps track of which test suites have been run since their dependencies have last changed and whether the run was successful (exit code 0, I guess). Then it doesn't rerun the test suite if it's already succeeded and the dependencies haven't changed.
13 remaining items
NorfairKing commentedon Apr 22, 2023
@ulysses4ever Every reverse-dependenty test suite is rerun when code changes, so there won't be false positives but sometimes too many test-runs.
hasufell commentedon Apr 23, 2023
Unlikely to happen, IMO.
But once the hooks design is actually generically implemented, you can run whatever you want before a build.
NorfairKing commentedon Apr 23, 2023
@hasufell Where can I follow up on that progress?
hasufell commentedon Apr 23, 2023
#7394
TeofilC commentedon Oct 28, 2023
I'm guessing this is referring to
stack dot? You can do something similar with cabal-planphilderbeast commentedon Nov 12, 2023
Stack warns about unused package flags, #7813 (comment)
NorfairKing commentedon Nov 18, 2024
Another cabal bug that stack hasn't:
cabal build alldoes not build all.https://x.com/kerckhove_ts/status/1858455925767500021
fgaz commentedon Nov 18, 2024
Eh, I disagree on it being a bug. If I choose to disable tests/benchmarks, I want them disabled. We could enable tests and/or benchmarks by default though (didn't we already do that?)
ulysses4ever commentedon Nov 18, 2024
I agree
cabal build allnot building all by default is a huge UX flaw. @fgaz if you want to disable some of it, you should be able to do so, of course, but this is a separate concern: e.g. if you addtests: Falsein your config or your project file, then, od course,cabal build allshouldn't build tests. The question here (as you rightly point out) is about the default behavior --- the one that applies when there are no explicit instructions from the user.And no, we didn't enable tests (#7883) and/or benchmarks by default. The last development on this front, I think, was enabling docs by default when the user calls
cabal haddock. That didn't go down well, though: #8725 Doing the same forcabal testled to another mega-thread but in the end, it looked like there was a path forward, and just no one bothered implementing it.I wonder if the easiest (and reasonable) way to improve that would be to generate the default config with
tests: True,benchmarks: True. We can mention in the docs that to avoid building tests/benches for a particular project you can alwayscabal configure --disable-tests --disable-benchmarks. The downside of this cheap solution would be that even when selecting a particular component (cabal build blah),cabalwill try to solve for everything (#4087).tbidne commentedon Nov 18, 2024
Another (backwards-compat) solution would be to introduce a new target
everythingthat solves and attempts to build literally all targets. This arguably would retroactively justifyall's current behavior, analogous to-Wallvs-Weverything.hasufell commentedon Nov 19, 2024
Let's not pretend that's good design. It's atrocious and after 10 years of Haskell I'd fail every interview that asks me what the difference of both GHC flags are.
philderbeast commentedon Jan 11, 2025
With #9744,
cabal-installwill be able to select and show a subset of targets . Thestack ide targetscommand was added to stack in Jun 2016.philderbeast commentedon Jan 11, 2025
As for the comments in this thread about
cabal build allbuilding or not building tests and benchmarks and whether "all" includes those and whethercabal buildshould be equivalent tocabal build all. All of this is much easier to explore with #9744. Here's an example from this repository (cabal targetis the same ascabal target all):Tests are included above because
cabal.projectenables them. Let's remove that1 and try again :Footnotes
cabal target --disable-testswould have had the same effect. ↩ulysses4ever commentedon Feb 9, 2025
An interesting feature was requested and implemented with respect to lockfile-like behavior in both tools:
--lockflag tocabal freezeto promote a freeze file to a lock file #10785