Added second executable to cabal file
[advent-of-code-16.git] / README.md
1 ---
2 title: "Advent of Code 2016"
3 output: html_document
4 css: modest.css
5 ---
6 Code to solve the [Advent of Code](http://adventofcode.com/2016/) puzzles. This year, I'm trying to use the puzzles as a prompt to learn [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 I have one package for each day, to 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.
19
20 Compile with
21 ```
22 stack build
23 ```
24 or
25 ```
26 stack build adventofcode1601
27 ```
28
29 Run with
30 ```
31 stack exec advent01
32 ```
33
34 Run interactively with
35 ```
36 stack ghci adventofcode1601:exe:advent01
37 ```
38
39 To profile, use
40 ```
41 stack build --executable-profiling --library-profiling -ghc-options="-fprof-auto -rtsopts" adventofcode1601
42 ```
43 then run with
44 ```
45 stack exec -- advent01 +RTS -p -hy
46 ```
47
48 # Readme
49
50 Build this readme file wth
51 ```
52 pandoc -s README.md > README.html
53 ```
54
55 ### Earlier instructions, for compiling before use of Stack
56
57 I'm also using some extra libraries. Before installing, run `cabal update` then set `library-profiling: True` in `~/.cabal/config` . Then install the packages with
58 ```
59 $ cabal install MissingH
60 $ cabal install parsec-numbers
61 $ cabal install cryptonite
62 $ cabal install pqueue
63 ```
64
65 Compile the code with
66 ```
67 ghc --make advent01.hs
68 ```
69
70 then run it as
71 ```
72 advent01
73 ```
74
75 If you're profiling, compile and run with
76 ```
77 ghc -O2 --make advent01.hs -prof -auto-all -caf-all -fforce-recomp -rstopts
78 time ./advent01 +RTS -p -hy
79 ```
80
81 and create the profile picture with `h2ps advent01.hp` .
82
83 (Using the [Modest style](https://github.com/markdowncss/modest).)