X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=README.md;h=17a29027d617b15661d148015f2033e6a0517413;hb=1ab3e062eb1b3b28a8aead9834afc962ca142451;hp=935b9387d264c128ecb74c698235692b7c0e7c95;hpb=30f2ac165744b80139e28c783aa4d0f0ac122e87;p=advent-of-code-21.git diff --git a/README.md b/README.md index 935b938..17a2902 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ Code to solve the [Advent of Code](http://adventofcode.com/2020/) puzzles. This [Learn you a Haskell](http://learnyouahaskell.com/chapters), [Introduction to Haskell 98](https://www.haskell.org/tutorial/index.html), and [Hackage](https://hackage.haskell.org/) are good resources. -The [Stack documentation](https://docs.haskellstack.org/en/stable/README/) and [How I Start: Haskell](http://howistart.org/posts/haskell/1/) are good sources of using the tools. - +The [Cabal user guide](https://cabal.readthedocs.io/en/latest/index.html) and [How I Start: Haskell](http://howistart.org/posts/haskell/1/) are good sources of using the tools. # Toolchain @@ -18,6 +17,8 @@ Install Ghcup following [the instructions](https://www.haskell.org/ghcup/install source /home/neil/.ghcup/env ``` +and then set the default GHC to use with `ghcup set ghc 9.0.1` . + Install [Haskell Language Server](https://haskell-language-server.readthedocs.io/en/latest/configuration.html) for Sublime Text @@ -36,7 +37,7 @@ Modify the `advent-of-code21.cabal` file as needed, such as updating the Cabal v ## Creating subsequent days -Each day lives in a separate directory, with its own `package.yaml` file and code in the `src` directory. (I based this configuration from [mstksg's setup](https://github.com/mstksg/advent-of-code-2018).) +Each day lives in a separate directory, with code in the `src` directory. Compile with ``` @@ -54,7 +55,7 @@ cabal run advent01 If you want to pass in additional RTS parameters, do it like this: ``` -stack exec -- advent01 +RTS -K0 -RTS +cabal run advent01 -- +RTS -K0 -RTS ``` Run interactively with @@ -67,25 +68,41 @@ stack ghci advent01:exe:advent01 ``` if the first form is ambiguous. +## Profiling + To profile, use + ``` -stack build --executable-profiling --library-profiling --ghc-options="-fprof-auto -rtsopts" advent01 +cabal run advent01 --enable-profiling -- +RTS -N -p -s -hT ``` -then run with + +Or, you can simplify the RTS options by adding them to a new stanza in the cabal file: + ``` -stack exec --profile -- advent01 +RTS -p -hy +executable advent01prof + import: common-extensions, build-directives + main-is: advent01/Main.hs + build-depends: text, containers, linear, array, pqueue, mtl, lens + ghc-options: -O2 + -Wall + -threaded + -rtsopts "-with-rtsopts=-N -p -s -hT" ``` -Generate the profile graph with + +then running + ``` -stack exec hp2ps advent01.hp +cabal run advent01prof --enable-profiling ``` -For Cabal, look at [profiling with Cabal sandboxes](https://nikita-volkov.github.io/profiling-cabal-projects/) +Generate the profile graph with +``` +hp2ps -M advent01.hp +``` -# Packages -Stack is using the [14.16-lts resolver](https://www.stackage.org/lts-16.25) for packages, so make sure you read the [correct documentation for the packages included in it](https://www.stackage.org/lts-16.25/docs). +# Packages Packages I used a lot: