X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=README.md;h=1556de04b324a05dc69a15a02432930ab26087b8;hb=HEAD;hp=a6eb1f7366f0c51c843b0af74379d5a0a0fccee7;hpb=3a599e34c0ddccec3e5c5d20a11fad920e4628c9;p=advent-of-code-17.git diff --git a/README.md b/README.md index a6eb1f7..1556de0 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,11 @@ Code to solve the [Advent of Code](http://adventofcode.com/2017/) 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. + # Toolchain -I'm using the basic Haskell Platform installation, togeher with `Stack` to manage the packages and dependencies (install with +I'm using the basic Haskell Platform installation, togeher with `stack` to manage the packages and dependencies (install with ``` $ sudo aptitude install haskell-platform haskell-stack ``` @@ -18,30 +20,19 @@ $ sudo aptitude install haskell-platform haskell-stack ## Creating the repository and project Create the repository as normal: create the project in Gitolite, clone it, and insert the `.gitignore` and `README.md` files. -Within the project directory, there will be one package for each day. This will save time waiting for `stack` to check every executable before compiling what's changed. Each package needs a separate directory tree and a separate `.cabal` file. - -## Creating the first package -Then create the basic `stack` project with it. This will create a new directory. Note that this new directory name can't have a hyphen-delimited word that's just digits, so the initial project will have to be `adventofcode1701` - -``` -stack new adventofcode1701 simple -``` - -This project will be demoted to being a package, but one that will hold the overall project. +There's just one package, with the code in sub-directories of the `src` directory. Each day will generate one (or more) entries in the `adventofcode17.cabal` file. -Then create the top-level `stack.yaml` file to hold the overall project information. +Create the basic `stack` project. This will create a new directory. Note that this new directory name can't have a hyphen-delimited word that's just digits, so the project will have to be `advent-of-code` ``` -stack init +stack new advent-of-code --bare simple ``` -Modify this top-level `stack.yaml` file as needed, such as adding the `ghc-options` stanza. You can then delete `adventofcode1701/stack.yaml`. +Modify the `stack.yaml` file as needed, such as adding the `ghc-options` stanza. -## Creating subsequent packages +## Creating subsequent days -Each package needs a separate directory tree and a separate `.cabal` file. - -To work on a project, `cd` into that project's directory. +Each day lives in a separate directory within the `src` directory. It will also need it's own stanza in `advent-of-code.cabal`. Compile with ``` @@ -49,7 +40,7 @@ stack build ``` or ``` -stack build adventofcode1701 +stack build advent01 ``` Run with @@ -59,7 +50,7 @@ stack exec advent01 Run interactively with ``` -stack ghci adventofcode1701:exe:advent01 +stack ghci advent-of-code:exe:advent01 ``` To profile, use @@ -71,6 +62,31 @@ then run with stack exec -- advent01 +RTS -p -hy ``` +# Packages + +Stack is using the [9.14-lts resolver](https://www.stackage.org/lts-9.14) for packages, so make sure you read the [correct documentation for the packages included in it](https://www.stackage.org/lts-9.14/docs). + +When you use a new package, use + +``` +stack solver +``` +to see how the `stack.yaml` file needs to change, and +``` +stack solver --update-yaml +``` +to implement the changes. + +# IHaskell + +Install following the [IHaskell instructions](https://github.com/gibiansky/IHaskell). + +Run it with + +``` +stack exec jupyter -- notebook +``` + # Readme Build this readme file wth