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
2017</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
2017</h1>
15 <p>Code to solve the
<a href=
"http://adventofcode.com/2017/">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 <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 <h2 id=
"creating-the-repository-and-project">Creating the repository and project
</h2>
22 <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>
23 <p>Within the project directory, there will be one package for each day. This will save time waiting for
<code>stack
</code> to check every executable before compiling what's changed. Each package needs a separate directory tree and a separate
<code>.cabal
</code> file.
</p>
24 <h2 id=
"creating-the-first-package">Creating the first package
</h2>
25 <p>Then create the basic
<code>stack
</code> 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
<code>adventofcode1701
</code></p>
26 <pre><code>stack new adventofcode1701 simple
</code></pre>
27 <p>This project will be demoted to being a package, but one that will hold the overall project.
</p>
28 <p>Then create the top-level
<code>stack.yaml
</code> file to hold the overall project information.
</p>
29 <pre><code>stack init
</code></pre>
30 <p>Modify this top-level
<code>stack.yaml
</code> file as needed, such as adding the
<code>ghc-options
</code> stanza. You can then delete
<code>adventofcode1701/stack.yaml
</code>.
</p>
31 <h2 id=
"creating-subsequent-packages">Creating subsequent packages
</h2>
32 <p>Each package needs a separate directory tree and a separate
<code>.cabal
</code> file.
</p>
33 <p>To work on a project,
<code>cd
</code> into that project's directory.
</p>
35 <pre><code>stack build
</code></pre>
37 <pre><code>stack build adventofcode1701
</code></pre>
39 <pre><code>stack exec advent01
</code></pre>
40 <p>Run interactively with
</p>
41 <pre><code>stack ghci adventofcode1701:exe:advent01
</code></pre>
42 <p>To profile, use
</p>
43 <pre><code>stack build --executable-profiling --library-profiling --ghc-options=
"-fprof-auto -rtsopts
" adventofcode1601
</code></pre>
45 <pre><code>stack exec -- advent01 +RTS -p -hy
</code></pre>
46 <h1 id=
"readme">Readme
</h1>
47 <p>Build this readme file wth
</p>
48 <pre><code>pandoc -s README.md
> README.html
</code></pre>
49 <p>(Using the
<a href=
"https://github.com/markdowncss/modest">Modest style
</a>.)
</p>