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 <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, togeher 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>
22 <h2 id=
"creating-the-repository-and-project">Creating the repository and project
</h2>
23 <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>
24 <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>
25 <h2 id=
"creating-the-first-package">Creating the first package
</h2>
26 <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>
27 <pre><code>stack new adventofcode1701 simple
</code></pre>
28 <p>This project will be demoted to being a package, but one that will hold the overall project.
</p>
29 <p>Then create the top-level
<code>stack.yaml
</code> file to hold the overall project information.
</p>
30 <pre><code>stack init
</code></pre>
31 <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>
32 <h2 id=
"creating-subsequent-packages">Creating subsequent packages
</h2>
33 <p>Each package needs a separate directory tree and a separate
<code>.cabal
</code> file.
</p>
34 <p>To work on a project,
<code>cd
</code> into that project's directory.
</p>
36 <pre><code>stack build
</code></pre>
38 <pre><code>stack build adventofcode1701
</code></pre>
40 <pre><code>stack exec advent01
</code></pre>
41 <p>Run interactively with
</p>
42 <pre><code>stack ghci adventofcode1701:exe:advent01
</code></pre>
43 <p>To profile, use
</p>
44 <pre><code>stack build --executable-profiling --library-profiling --ghc-options=
"-fprof-auto -rtsopts
" adventofcode1601
</code></pre>
46 <pre><code>stack exec -- advent01 +RTS -p -hy
</code></pre>
47 <h1 id=
"ihaskell">IHaskell
</h1>
48 <p>Install following the
<a href=
"https://github.com/gibiansky/IHaskell">IHaskell instructions
</a>.
</p>
49 <p>To run, change into the package's directory (after modifying the
<code>.cabal
</code> file) and run it with
</p>
50 <pre><code>stack exec jupyter -- notebook
</code></pre>
51 <h1 id=
"readme">Readme
</h1>
52 <p>Build this readme file wth
</p>
53 <pre><code>pandoc -s README.md
> README.html
</code></pre>
54 <p>(Using the
<a href=
"https://github.com/markdowncss/modest">Modest style
</a>.)
</p>