1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns=
"http://www.w3.org/1999/xhtml">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css" />
6 <meta name=
"generator" content=
"pandoc" />
7 <title>Advent of Code
2016</title>
8 <style type=
"text/css">code{white-space: pre;}
</style>
9 <link rel=
"stylesheet" href=
"modest.css" type=
"text/css" />
13 <h1 class=
"title">Advent of Code
2016</h1>
15 <p>Code to solve the
<a href=
"http://adventofcode.com/2016/">Advent of Code
</a> puzzles. This year, I'm trying to use the puzzles as a prompt to learn
<a href=
"https://wiki.haskell.org/Haskell">Haskell
</a>.
</p>
16 <p><a href=
"http://learnyouahaskell.com/chapters">Learn you a Haskell
</a>,
<a href=
"https://www.haskell.org/tutorial/index.html">Introduction to Haskell
98</a>, and
<a href=
"https://hackage.haskell.org/">Hackage
</a> are good resources.
</p>
17 <h1 id=
"toolchain">Toolchain
</h1>
18 <p>I'm using the basic Haskell Platform installation, togeher with
<code>Stack
</code> to manage the packages and dependencies (install with
</p>
19 <pre><code>$ sudo aptitude install haskell-platform haskell-stack
</code></pre>
21 <p>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
<code>.cabal
</code> file.
</p>
23 <pre><code>stack build
</code></pre>
25 <pre><code>stack build adventofcode1601
</code></pre>
27 <pre><code>stack exec advent01
</code></pre>
28 <p>Run interactively with
</p>
29 <pre><code>stack ghci adventofcode1601:exe:advent01
</code></pre>
30 <p>To profile, use
</p>
31 <pre><code>stack build --executable-profiling --library-profiling -ghc-options=
"-fprof-auto -rtsopts
" adventofcode1601
</code></pre>
33 <pre><code>stack exec -- advent01 +RTS -p -hy
</code></pre>
34 <h1 id=
"readme">Readme
</h1>
35 <p>Build this readme file wth
</p>
36 <pre><code>pandoc -s README.md
> README.html
</code></pre>
37 <h3 id=
"earlier-instructions-for-compiling-before-use-of-stack">Earlier instructions, for compiling before use of Stack
</h3>
38 <p>I'm also using some extra libraries. Before installing, run
<code>cabal update
</code> then set
<code>library-profiling: True
</code> in
<code>~/.cabal/config
</code> . Then install the packages with
</p>
39 <pre><code>$ cabal install MissingH
40 $ cabal install parsec-numbers
41 $ cabal install cryptonite
42 $ cabal install pqueue
</code></pre>
43 <p>Compile the code with
</p>
44 <pre><code>ghc --make advent01.hs
</code></pre>
46 <pre><code>advent01
</code></pre>
47 <p>If you're profiling, compile and run with
</p>
48 <pre><code>ghc -O2 --make advent01.hs -prof -auto-all -caf-all -fforce-recomp -rstopts
49 time ./advent01 +RTS -p -hy
</code></pre>
50 <p>and create the profile picture with
<code>h2ps advent01.hp
</code> .
</p>
51 <p>(Using the
<a href=
"https://github.com/markdowncss/modest">Modest style
</a>.)
</p>