A follow along project for Haskell fundamentals workshop. Emphasizes practical solutions in Haskell, and covers the range of concepts needed to use Haskell in industry.
To ensure you have a working system, make sure you can run stack run
You should see the string someFunc
as the output
Choose one of the following options
- Install Nix
- Enable nix flakes experimental feature
cd haskell-project-example
nix develop
stack run
- Globally install haskell-language-server
- Ensure editor has lsp client
- Follow editor specific instructions on setting up lsp client and haskell-language-server
Direnv loads the project shell environment when you cd
into the directory.
Combined with nix this allows reproducibility and eases dev setup.
It allows declaring all global dependencies (especially dev dependencies) within the project as executable code rather than documentation.
- Install Nix
- Enable nix flakes experimental feature
- Install Direnv
cd haskell-project-example
echo "use flake" > .envrc
direnv allow
stack run
- Ensure editor has direnv extension installed. This ensures that the editor picks up dev tools like haskell-language-server. The below are examples, not necessarily recommendations
- emacs: emacs-direnv
- vim: direnv.vim
- vscode: direnv
If you prefer not to use nix then using stack works as usual. In this case you can set up editor tools globally.
stack build
stack run
- Globally install haskell-language-server
- Ensure editor has lsp client
- Follow editor specific instructions on setting up lsp client and haskell-language-server
export ALPACAKEY=${fill_me_in}
export ALPACASECRET=${fill_me_in}
export LD_LIBRARY_PATH=$PWD/number-munch/target/debug:$LD_LIBRARY_PATH
Reference for rts options
https://downloads.haskell.org/~ghc/9.0.1/docs/html/users_guide/profiling.html
- example useful commands
- time profiling
stack --profile run --rts-options -p # get allocation in bytes for each cost centre stack --profile run --rts-options -pa # get heap profile based on cost centres stack --profile run --rts-options -hc # get heap profile based on types stack --profile run --rts-options -hy # heap profiling produces .hp file. Convert it to postscript with hp2ps hp2ps -c -e540 ./api.hp # For memory issues it is sometimes useful to limit heap or stack size +RTS -M4m -RTS
Must watch video