Help setting up Cabal project with HUnit tests

For a while, I struggled with project-setup details like this. A resource that has helped improve that experience a lot, is the stack project templates (GitHub - commercialhaskell/stack-templates: Project templates for stack new). Try them out, I think they speak for themselves. For example, there is an hspec template even (stack-templates/hspec.hsfiles at master · commercialhaskell/stack-templates · GitHub). You can access it with stack like so:

$ stack new explore-hspec hspec
$ cd explore-hspec
$ stack build --test

In the end, you should see some output like:

image

The directory layout and details of .cabal/etc files are all there for exploration and learning. But it comes working out of the box, so very approachable and a nice foundation to start a project on. I use the rio, simple, and yesodweb/minimal templates a lot :slight_smile:

YMMV!

1 Like