Skip to content

Feature parity with Stack #8605

Open
Open

Description

@NorfairKing

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:

Not available and not desirable IMO:

  • GHC installation

UPD More ideas from the discussion below:

Activity

  1. ulysses4ever commented on Nov 18, 2022

    @ulysses4ever
    Collaborator

    Would help to have links to respective stack documentation sections.

  2. NorfairKing commented on Nov 18, 2022

    @NorfairKing
    Author

    @ulysses4ever Good idea, I added some links.

  3. tfausak commented on Nov 18, 2022

    @tfausak
    Collaborator

    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 build all --file-watch

    Automatically executing hpack

  4. fgaz commented on Nov 18, 2022

    @fgaz
    Member
  5. chrisdone-artificial commented on Nov 18, 2022

    @chrisdone-artificial

    Regarding feature parity

    • 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!

  6. fgaz commented on Nov 18, 2022

    @fgaz
    Member

    Loading multiple packages in cabal repl

    specifying a Stackage snapshot in one line

    the fact that I can then cherry-pick and pin individual package versions

    Personally, I think GHC management is a big deal

  7. xplat commented on Nov 18, 2022

    @xplat

    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.)

  8. gbaz commented on Nov 18, 2022

    @gbaz
    Collaborator

    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.

  9. JakobBruenker commented on Nov 18, 2022

    @JakobBruenker

    Not available and not desirable IMO:

    • GHC installation

    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.

  10. merijn commented on Nov 18, 2022

    @merijn
    Collaborator

    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.

  11. JakobBruenker commented on Nov 18, 2022

    @JakobBruenker

    @merijn that is good to know, thank you

  12. NorfairKing commented on Nov 19, 2022

    @NorfairKing
    Author

    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.

  13. 13 remaining items

  14. NorfairKing commented on Apr 22, 2023

    @NorfairKing
    Author

    @ulysses4ever Every reverse-dependenty test suite is rerun when code changes, so there won't be false positives but sometimes too many test-runs.

  15. hasufell commented on Apr 23, 2023

    @hasufell
    Member

    Automatically running hpack when necessary

    Unlikely to happen, IMO.

    But once the hooks design is actually generically implemented, you can run whatever you want before a build.

  16. NorfairKing commented on Apr 23, 2023

    @NorfairKing
    Author

    @hasufell Where can I follow up on that progress?

  17. hasufell commented on Apr 23, 2023

    @hasufell
    Member
  18. TeofilC commented on Oct 28, 2023

    @TeofilC
    Member

    Dependency graph

    I'm guessing this is referring to stack dot? You can do something similar with cabal-plan

  19. philderbeast commented on Nov 12, 2023

    @philderbeast
    Collaborator

    Stack warns about unused package flags, #7813 (comment)

  20. NorfairKing commented on Nov 18, 2024

    @NorfairKing
    Author
  21. fgaz commented on Nov 18, 2024

    @fgaz
    Member

    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?)

  22. ulysses4ever commented on Nov 18, 2024

    @ulysses4ever
    Collaborator

    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).

  23. tbidne commented on Nov 18, 2024

    @tbidne
    Contributor

    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.

  24. hasufell commented on Nov 19, 2024

    @hasufell
    Member

    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.

  25. philderbeast commented on Jan 11, 2025

    @philderbeast
    Collaborator

    With #9744, cabal-install will be able to select and show a subset of targets . The stack ide targets command was added to stack in Jun 2016.

  26. philderbeast commented on Jan 11, 2025

    @philderbeast
    Collaborator

    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):

    $ cabal run cabal-install:exe:cabal -- target
    ...
    Fully qualified target forms:
     - Cabal-QuickCheck:lib:Cabal-QuickCheck
     - Cabal-described:lib:Cabal-described
     - Cabal-hooks:lib:Cabal-hooks
     - Cabal-syntax:lib:Cabal-syntax
     - Cabal-tests:lib:Cabal-tests
     - Cabal-tests:test:check-tests
     - Cabal-tests:test:custom-setup-tests
     - Cabal-tests:test:hackage-tests
     - Cabal-tests:test:no-thunks-test
     - Cabal-tests:test:parser-tests
     - Cabal-tests:test:rpmvercmp
     - Cabal-tests:test:unit-tests
     - Cabal-tree-diff:lib:Cabal-tree-diff
     - Cabal:lib:Cabal
     - buildinfo-reference-generator:exe:buildinfo-reference-generator
     - cabal-benchmarks:test:cabal-benchmarks
     - cabal-install-solver:lib:cabal-install-solver
     - cabal-install-solver:test:unit-tests
     - cabal-install:exe:cabal
     - cabal-install:lib:cabal-install
     - cabal-install:test:integration-tests2
     - cabal-install:test:long-tests
     - cabal-install:test:mem-use-tests
     - cabal-install:test:unit-tests
     - cabal-testsuite:exe:cabal-tests
     - cabal-testsuite:exe:setup
     - cabal-testsuite:exe:test-runtime-deps
     - cabal-testsuite:lib:cabal-testsuite
     - cabal-validate:exe:cabal-validate
     - solver-benchmarks:exe:hackage-benchmark
     - solver-benchmarks:lib:solver-benchmarks
     - solver-benchmarks:test:unit-tests
    Found 29 targets matching all.
    

    Tests are included above because cabal.project enables them. Let's remove that1 and try again :

    $ git diff
    diff --git a/cabal.project b/cabal.project
    index a2075cfdc..c2742cd46 100644
    --- a/cabal.project
    +++ b/cabal.project
    @@ -3,7 +3,6 @@ import: project-cabal/ghc-latest.config
     import: project-cabal/pkgs.config
     import: project-cabal/constraints.config
     
    -tests: True
    $ cabal run cabal-install:exe:cabal -- target
    ...
    Fully qualified target forms:
     - Cabal-QuickCheck:lib:Cabal-QuickCheck
     - Cabal-described:lib:Cabal-described
     - Cabal-hooks:lib:Cabal-hooks
     - Cabal-syntax:lib:Cabal-syntax
     - Cabal-tests:lib:Cabal-tests
     - Cabal-tree-diff:lib:Cabal-tree-diff
     - Cabal:lib:Cabal
     - buildinfo-reference-generator:exe:buildinfo-reference-generator
     - cabal-install-solver:lib:cabal-install-solver
     - cabal-install:exe:cabal
     - cabal-install:lib:cabal-install
     - cabal-testsuite:exe:cabal-tests
     - cabal-testsuite:exe:setup
     - cabal-testsuite:exe:test-runtime-deps
     - cabal-testsuite:lib:cabal-testsuite
     - cabal-validate:exe:cabal-validate
     - solver-benchmarks:exe:hackage-benchmark
     - solver-benchmarks:lib:solver-benchmarks
    Found 15 targets matching all.
    

    Footnotes

    1. cabal target --disable-tests would have had the same effect. ↩

  27. ulysses4ever commented on Feb 9, 2025

    @ulysses4ever
    Collaborator

    An interesting feature was requested and implemented with respect to lockfile-like behavior in both tools:

  28. added
    re: globbing
    on May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions