After my question about what’s changed in Haskell, I’m trying the new cabal for the first time in years. I’m an experienced Haskeller, but I’ve always used stack, so my experience may be comparable to first-time users.
I’m following the Cabal Quickstart and I’m running into lots of issues.
-
First, I had ghcup installed already, so when I went to install all the latest goodies, I ran into some issues, including a mysterious segfault, due to not realizing I needed to “set” ghcup to the latest. Then once I did, lots of other problems because I had run
cabal init
before setting it to the latest. Confusing, but that’s on me, and most users won’t have old installs. -
Ok, I have a new project. I follow the interactive prompts to make an “executable” project.
cabal run
works! Now I load the project into vscode and HLS creates some popups, but then does… nothing. I can create errors and it doesn’t detect them. Weird. I restart HLS and works once, but won’t update. -
Without having figured out how to get HLS to update automatically, I try adding a second file: Test.hs, and HLS gives me the following error. I’m confused, I google it, and it isn’t immediately obvious what the problem is.
Multi Cradle: No prefixes matched
pwd: /Users/sean/Documents/code/apocalypse-generator/mcgen
filepath: /Users/sean/Documents/code/apocalypse-generator/mcgen/app/Test.hs
prefixes:
("app/Main.hs",Cabal {component = Just "mcgen:exe:mcgen"})
- So I try
cabal run
again for kicks, and now the error makes sense. I have to add every source file to my .cabal file? That’s unintuitive and painful. I used to use stack with hpack integration and it was automatic.
<no location info>: warning: [GHC-32850] [-Wmissing-home-modules]
These modules are needed for compilation but not listed in your .cabal file's other-modules for ‘main’ :
Test
Adding Test to other-modules and restarting HLS makes it start updating as expected.
What’s the best way to create a cabal project that automatically includes source files in other-modules? I’m not publishing a library so I don’t need fine-grained control.
How can I help make this experience better for first-time users? I think most non-haskell programmers would get stuck and give up experiencing the above.
Thanks!