to install haskell stack
curl -sSL https://get.haskellstack.org/ | sh
in a minimal project the simplest files looks like
main :: IO () main = putStrLn "Hello, world!"
name: package_name version: 0.0.1 build-type: Simple executable hello main-is: Main.hs build-depends: base < 5
import Distribution.Simple main = defaultMain
Then you write
cabal build and the program compiles into the dist/ folder. To run the program you can use:
In order to make this proyect stack aware, we need to add a
stack.yaml file in the same directory.
resolver: lts-8.8 packages: - .
(I add a line for
cabal-version: >= 1.2 to my hello.cabal file because stack complains about it)
Cabal is for managing packages
Stack is for managing projects
take a look to the turtle package on hackage (http://hackage.haskell.org/package/turtle)
in stack it use the resolver to select which version to choose. (example for the lts-8.8 resolver: https://www.stackage.org/lts-8.8/cabal.config)
you can make cabal resolve dependencies from a stack resolver coping the resolver cabal.config to the root of the project.
if you want to use a dependency stored in your filesystem you can use (stack.yaml file):
resolver: lts-8.8 packages: - . - location: /home/carlos/my_library extra-dep: true
- if you want to use a dependency stored in github you can use (stack.yaml file):
resolver: lts-8.8 packages: - . - location: git: https://github.com/Gabriel439/Haskell-Turtle-Library.git commit: e000a88d2c9f21809ce3e56963ab9cf8d3f31082
you can create projects using stack from templates
stack templatesgives you the list of templates included
stack new project_name TEMPLATE-NAMEcreates your project from the template.
you can make stack to be aware of the source files changes using
stack test --file-watch, if you change any file, this will rebuild and retest the project everytime you save.
take a look to