The Haskell wiki states that you should use Cabal as your build system. However, it seems to me much more directed at producing packages then just building binaries. Basically, all I want to do is build every *.hs file in my src/ directory into a seperate binary in bin/. This makefile accomplishes this nicely, but I want to learn about Cabal and this seems like a good example to get me started:
GHC = ghc
GHCFLAGS = -outputdir bin
SRC = $(wildcard src/*.hs)
BIN = $(patsubst src/%.hs,%,$(SRC))
all: $(addprefix bin/, $(BIN))
bin/%: src/%.hs
$(GHC) $(GHCFLAGS) $< -o $@
clean:
rm bin/*
Package versus projectStack is a build tool and it uses Cabal, a build system. Cabal defines the concept of a package. A package has: A name and version.
Using Cabal By default stack installs packages to ~/. cabal and ~/. ghc in your home directory.
The easiest way to get started is to have Cabal generate a .cabal
file for you that you can use as a starting point. To do this, go into your project directory and type
$ cabal init
It will then ask you a bunch of questions about your package. Some questions like author name and email only really matter if you plan on uploading your package to Hackage, so you can leave those blank if you want. After doing that, you can then edit the .cabal
file to customize it. The generated file will contain a bunch of comments which should help you get started. After that, simply type
$ cabal configure
$ cabal build
The binary will by default be placed in ./dist/build/<name>/
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With