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>Summer of Code
2018</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">Summer of Code
2018</h1>
15 <p>Code to solve the
<a href=
"https://learn2.open.ac.uk/course/view.php?id=206891">Summer of Code
</a> puzzles. These sample solutions are in
<a href=
"https://www.python.org/">Python
</a> and
<a href=
"https://wiki.haskell.org/Haskell">Haskell
</a>.
</p>
16 <h1 id=
"python">Python
</h1>
17 <p>I develop the solutions with
<a href=
"https://github.com/jupyterlab/">Jupyter Lab
</a>.
</p>
18 <h1 id=
"haskell">Haskell
</h1>
19 <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>
20 <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>
21 <h2 id=
"toolchain">Toolchain
</h2>
22 <p>I'm using the basic Haskell Platform installation, togeher with
<code>stack
</code> to manage the packages and dependencies (install with
</p>
23 <pre><code>$ sudo aptitude install haskell-platform haskell-stack
</code></pre>
25 <h3 id=
"creating-the-repository-and-project">Creating the repository and project
</h3>
26 <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>
27 <p>There's just one package, with the code in sub-directories of the
<code>src
</code> directory. Each day will generate one (or more) entries in the
<code>summerofcode2018soln.cabal
</code> file.
</p>
28 <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>
29 <pre><code>stack new summerofcode2018soln --bare simple
</code></pre>
30 <p>Modify the
<code>stack.yaml
</code> file as needed, such as adding the
<code>ghc-options
</code> stanza.
</p>
31 <h3 id=
"creating-subsequent-days">Creating subsequent days
</h3>
32 <p>Each day lives in a separate directory within the
<code>src
</code> directory. It will also need it's own stanza in
<code>summerofcode2018.cabal
</code>.
</p>
34 <pre><code>stack build
</code></pre>
36 <pre><code>stack build task1
</code></pre>
38 <pre><code>stack exec task1
</code></pre>
39 <p>Run interactively with
</p>
40 <pre><code>stack ghci summerofcode2018soln:exe:task1
</code></pre>
41 <p>To profile, use
</p>
42 <pre><code>stack build --executable-profiling --library-profiling --ghc-options=
"-fprof-auto -rtsopts
" task1
</code></pre>
44 <pre><code>stack exec -- task1 +RTS -p -hy
</code></pre>
45 <h2 id=
"packages">Packages
</h2>
46 <p>Stack is using the
<a href=
"https://www.stackage.org/lts-12.9">12.9-lts resolver
</a> for packages, so make sure you read the
<a href=
"https://www.stackage.org/lts-12.9/docs">correct documentation for the packages included in it
</a>.
</p>
47 <p>When you use a new package, use
</p>
48 <pre><code>stack solver
</code></pre>
49 <p>to see how the
<code>stack.yaml
</code> file needs to change, and
</p>
50 <pre><code>stack solver --update-yaml
</code></pre>
51 <p>to implement the changes.
</p>
52 <h1 id=
"readme">Readme
</h1>
53 <p>Build this readme file wth
</p>
54 <pre><code>pandoc -s README.md
> README.html
</code></pre>
55 <p>(Using the
<a href=
"https://github.com/markdowncss/modest">Modest style
</a>.)
</p>