Day 15 done
[advent-of-code-19.git] / README.html
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">
3 <head>
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 2019</title>
8 <style type="text/css">code{white-space: pre;}</style>
9 <link rel="stylesheet" href="modest.css" type="text/css" />
10 </head>
11 <body>
12 <div id="header">
13 <h1 class="title">Advent of Code 2019</h1>
14 </div>
15 <p>Code to solve the <a href="http://adventofcode.com/2019/">Advent of Code</a> puzzles. This year, I'm using the puzzles to develop my skills in <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 <p>The <a href="https://docs.haskellstack.org/en/stable/README/">Stack documentation</a> and <a href="http://howistart.org/posts/haskell/1/">How I Start: Haskell</a> are good sources of using the tools.</p>
18 <h1 id="toolchain">Toolchain</h1>
19 <p>I'm using the basic Haskell Platform installation, together with <code>stack</code> to manage the packages and dependencies (install with</p>
20 <pre><code>$ sudo aptitude install haskell-platform haskell-stack</code></pre>
21 <p>), then updgrade with</p>
22 <pre><code> stack upgrade --binary-only</code></pre>
23 <p>as the version in the Ubuntu repos is too old to work with current Haskell Stack package sets.</p>
24 <h2 id="creating-the-repository-and-project">Creating the repository and project</h2>
25 <p>Create the repository as normal: create the project in Gitolite, clone it, and insert the <code>.gitignore</code> and <code>README.md</code> files.</p>
26 <p>There's one package per day, with the code for each package in sub-directories of the root directory.</p>
27 <p>Create the basic <code>stack</code> 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 <code>advent-of-code</code></p>
28 <pre><code>stack new advent-of-code --bare simple</code></pre>
29 <p>Modify the <code>stack.yaml</code> file as needed, such as adding the <code>ghc-options</code> stanza.</p>
30 <h2 id="creating-subsequent-days">Creating subsequent days</h2>
31 <p>Each day lives in a separate directory, with its own <code>package.yaml</code> file and code in the <code>src</code> directory. (I based this configuration from <a href="https://github.com/mstksg/advent-of-code-2018">mstksg's setup</a>.)</p>
32 <p>Compile with</p>
33 <pre><code>stack build</code></pre>
34 <p>or</p>
35 <pre><code>stack build advent01</code></pre>
36 <p>Run with</p>
37 <pre><code>stack exec advent01</code></pre>
38 <p>If you want to pass in additional RTS parameters, do it like this:</p>
39 <pre><code>stack exec -- advent01 +RTS -K0 -RTS</code></pre>
40 <p>Run interactively with</p>
41 <pre><code>stack ghci advent01</code></pre>
42 <p>or</p>
43 <pre><code>stack ghci advent01:exe:advent01</code></pre>
44 <p>if the first form is ambiguous.</p>
45 <p>To profile, use</p>
46 <pre><code>stack build --executable-profiling --library-profiling --ghc-options=&quot;-fprof-auto -rtsopts&quot;</code></pre>
47 <p>then run with</p>
48 <pre><code>stack exec -- advent01 +RTS -p -hy</code></pre>
49 <p>Generate the profile graph with</p>
50 <pre><code>stack exec hp2ps advent01.hp</code></pre>
51 <h1 id="packages">Packages</h1>
52 <p>Stack is using the <a href="https://www.stackage.org/lts-14.16">14.16-lts resolver</a> for packages, so make sure you read the <a href="https://www.stackage.org/lts-14.16/docs">correct documentation for the packages included in it</a>.</p>
53 <p>When you use a new package, use</p>
54 <pre><code>stack solver</code></pre>
55 <p>to see how the <code>stack.yaml</code> file needs to change, and</p>
56 <pre><code>stack solver --update-yaml</code></pre>
57 <p>to implement the changes.</p>
58 <h1 id="readme">Readme</h1>
59 <p>Build this readme file wth</p>
60 <pre><code>pandoc -s README.md &gt; README.html</code></pre>
61 <p>(Using the <a href="https://github.com/markdowncss/modest">Modest style</a>.)</p>
62 </body>
63 </html>