- Stack is a build tool
- Stack is not a package manager
- Curated package lists known to have no conflicts:
resolvers
- Sandbox builds by default
- Reproducible builds
- Install packages globally using a given resolver
# outside of any stack projects
stack --resolver=lts-10.10 install hindent
- Common packages to install globally
stack --resolver=lts-10.10 install hlint hindent stylish-haskell
-
package.yaml
-
Other way to generate cabal config files
- Simplicity
- Focus on Essentials
- Less boilerplate
-
Generate
.cabal
file with hpack
hpack
- Package and dependency manager
- Organize package with .cabal file
- Stack is a layer on top of cabal
# stack.yaml
docker:
enable: true
- Pass environment variables to the docker container
stack ghci --docker-env "FOO=BAR"
stack ghci --docker-env "FOO=BAR" --docker-env "BAZ=FOOZ"
- Creating new stack project
stack new project-name
- Build a target
stack build <target>
-
Never use
stack install
-
Build project without optimization, for development
stack build --fast
- Run tests along with the code
stack test --fast
stack build --fast --test
- Build documentation
stack test --fast --haddock-deps
- Rerun tests as code changes
stack test --fast --haddock-deps --file-watch
- Force everything to be re-built, removes local cache
stack clean
- Run specified executable from latest build
stack exec name-exe
- Run ghci
stack ghci
- Open local documentation
stack haddock --open lens
- Build the Hoogle Search Index
stack hoogle -- generate --local
- Start Hoogle local webserver
stack hoogle -- server --local --port=8080
stack.yaml
project.cabal
ORproject.yaml
that generates the cabal file- Online Documentation
- Build ghc-mod, hlint, hoogle, ...
stack build ghc-mod hlint hoogle
- GHC will create a program if there is a module named
Main
and amain
function. Otherwise use the-is-main
ghc flag.
stack ghc -- -O2 src/Map.hs -main-is Map.main && src/Map
- Incomplete Pattern Matching
-Wincomplete-uni-patterns
- Runtime Failable Record Update
-Wincomplete-record-updates
- Redundant Constraints
-Wredundant-constraints
- Missing Export List
-Wmissing-export-lists
- Treat Warnings as Errors (use in CI only)
-Werror