Updated readme
[advent-of-code-17.git] / README.md
1 ---
2 title: "Advent of Code 2017"
3 output: html_document
4 css: modest.css
5 ---
6 Code to solve the [Advent of Code](http://adventofcode.com/2017/) puzzles. This year, I'm using the puzzles to develop my skills in [Haskell](https://wiki.haskell.org/Haskell).
7
8 [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.
9
10 # Toolchain
11
12 I'm using the basic Haskell Platform installation, togeher with `Stack` to manage the packages and dependencies (install with
13 ```
14 $ sudo aptitude install haskell-platform haskell-stack
15 ```
16 ).
17
18 ## Creating the repository and project
19 Create the repository as normal: create the project in Gitolite, clone it, and insert the `.gitignore` and `README.md` files.
20
21 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.
22
23 ## Creating the first package
24 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`
25
26 ```
27 stack new adventofcode1701 simple
28 ```
29
30 This project will be demoted to being a package, but one that will hold the overall project.
31
32 Then create the top-level `stack.yaml` file to hold the overall project information.
33
34 ```
35 stack init
36 ```
37
38 Modify this top-level `stack.yaml` file as needed, such as adding the `ghc-options` stanza. You can then delete `adventofcode1701/stack.yaml`.
39
40 ## Creating subsequent packages
41
42 Each package needs a separate directory tree and a separate `.cabal` file.
43
44 To work on a project, `cd` into that project's directory.
45
46 Compile with
47 ```
48 stack build
49 ```
50 or
51 ```
52 stack build adventofcode1701
53 ```
54
55 Run with
56 ```
57 stack exec advent01
58 ```
59
60 Run interactively with
61 ```
62 stack ghci adventofcode1701:exe:advent01
63 ```
64
65 To profile, use
66 ```
67 stack build --executable-profiling --library-profiling --ghc-options="-fprof-auto -rtsopts" adventofcode1601
68 ```
69 then run with
70 ```
71 stack exec -- advent01 +RTS -p -hy
72 ```
73
74 # IHaskell
75
76 Install following the [IHaskell instructions](https://github.com/gibiansky/IHaskell).
77
78 To run, change into the package's directory (after modifying the `.cabal` file) and run it with
79
80 ```
81 stack exec jupyter -- notebook
82 ```
83
84 # Readme
85
86 Build this readme file wth
87 ```
88 pandoc -s README.md > README.html
89 ```
90
91 (Using the [Modest style](https://github.com/markdowncss/modest).)