<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Stack cookbook – Haskell – Aelve Guide</title><id>https://guide.aelve.com/haskell/feed/category/ai0adh03</id><updated>2019-03-09T22:51:27Z</updated><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/feed/category/ai0adh03"/><entry><id>pot9hfs3</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Docker integration</title><updated>2019-03-09T22:51:27Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;Docker integration&lt;/span&gt;

&lt;/h1&gt;&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# stack.yaml&lt;/span&gt;

&lt;span class=&#34;fu&#34;&gt;docker:&lt;/span&gt;
  &lt;span class=&#34;fu&#34;&gt;enable:&lt;/span&gt; true&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# Download the image&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; docker pull

&lt;span class=&#34;co&#34;&gt;# And then build as usual!&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; build --fast&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Stack can automatically download a Docker image with GHC and snapshot libraries installed, and build your project inside of it.&lt;/p&gt;
&lt;p&gt;TODO: docs say &amp;quot;FP Complete provides images for use with stack that include GHC, tools, and optionally have all of the Stackage LTS packages pre-installed in the global package database&amp;quot;, but the image chosen by Stack doesn&#39;t have any LTS packages pre-installed. How come?&lt;/p&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/stack-cookbook-ai0adh03#item-pot9hfs3"/></entry><entry><id>dxgyjikw</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Troubleshooting</title><updated>2019-03-09T20:48:42Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;Troubleshooting&lt;/span&gt;

&lt;/h1&gt;&lt;p&gt;If you suspect that an executable is not being rebuilt, or if something is wrong with dependency versions, etc:&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# Remove build artifacts for all packages in the project&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; clean

&lt;span class=&#34;co&#34;&gt;# Remove build artifacts for a specific package&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; clean &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;package&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&#34;co&#34;&gt;# Remove build artifacts and everything from .stack-work&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; clean --full&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If a dependency is broken and you&#39;re getting weird creepy errors you haven&#39;t ever seen before:&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# Remove a package from the local package database&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; exec -- ghc-pkg unregister &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;package&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you&#39;re really, truly desperate and you&#39;ve tried everything else (including setting your hair on fire):&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# An exciting journey of rebuilding hundreds of packages awaits you&lt;/span&gt;
&lt;span class=&#34;fu&#34;&gt;rm&lt;/span&gt; -rf ~/.stack&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/stack-cookbook-ai0adh03#item-dxgyjikw"/></entry><entry><id>e02mklpj</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Running executables</title><updated>2019-03-09T20:42:59Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;Running executables&lt;/span&gt;

&lt;/h1&gt;&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# Run an executable built with &#39;stack build&#39;&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; exec &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;executable name&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&#34;co&#34;&gt;# Run an executable and pass arguments to it&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; exec -- &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;executable name&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;arguments...&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# Run something (e.g. GHC) from a particular snapshot&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; exec --resolver=lts-12.10 -- ghc --version

&lt;span class=&#34;co&#34;&gt;# Run something from a particular GHC version distributive&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; exec --resolver=ghc-8.6.3 -- ghc --version&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;stack exec&lt;/code&gt; runs an executable in the context of the current project. It can be something built as a part of your project, but can also be a tool like &lt;code&gt;ghc&lt;/code&gt;, &lt;code&gt;cabal&lt;/code&gt;, &lt;code&gt;haddock&lt;/code&gt;, or &lt;code&gt;ghc-pkg&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# Build it, then run an executable&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; run &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;executable name&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;arguments...&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&#34;co&#34;&gt;# Build it, then run the first specified executable of the package&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; run&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the latest release, you can also use the new &lt;code&gt;stack run&lt;/code&gt; command to build the package and then run the specified executable. If your package contains an executable, you can just use plain &lt;code&gt;stack run&lt;/code&gt; to build and run this executable.&lt;/p&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/stack-cookbook-ai0adh03#item-e02mklpj"/></entry><entry><id>mrhj4gyl</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Running without stack.yaml</title><updated>2019-03-09T16:34:21Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;Running without stack.yaml&lt;/span&gt;

&lt;/h1&gt;&lt;p&gt;When there&#39;s no &lt;code&gt;stack.yaml&lt;/code&gt; in the current directory or up the path, the &lt;a href=&#34;https://docs.haskellstack.org/en/stable/GUIDE/#finding-project-configs-and-the-implicit-global-project&#34;&gt;global project&lt;/a&gt; will be used.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;stack install&lt;/code&gt; installs a library/executable into the global project, and &lt;code&gt;stack repl&lt;/code&gt; can access everything in the global project.&lt;/p&gt;
&lt;p&gt;Global project settings can be changed:&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# ~/.stack/global-project/stack.yaml&lt;/span&gt;

&lt;span class=&#34;fu&#34;&gt;packages:&lt;/span&gt; &lt;span class=&#34;kw&#34;&gt;[]&lt;/span&gt;
&lt;span class=&#34;fu&#34;&gt;resolver:&lt;/span&gt; lts-12.10&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/stack-cookbook-ai0adh03#item-mrhj4gyl"/></entry><entry><id>q9wsa91k</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Nix integration</title><updated>2019-03-09T15:39:58Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;Nix integration&lt;/span&gt;

&lt;/h1&gt;&lt;p&gt;Nix package manager can be used to install GHC and packages.
Normally, this can speed up the compilation of packages and avoids duplicate installations of identical packages.
To enable nix support, add to your &lt;code&gt;stack.yaml&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;fu&#34;&gt;nix:&lt;/span&gt;
  &lt;span class=&#34;fu&#34;&gt;enable:&lt;/span&gt; true&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;However, this is generally not suggested, because this will automatically use nix on systems that might not have it installed, thus, the build fails.
It is better to add the above lines to your yaml config template: &lt;code&gt;~/.stack/config.yaml&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Nix automatically handles system library dependencies. Such dependencies can be added by modifying your local &lt;code&gt;stack.yaml&lt;/code&gt;, for example, if you require &lt;code&gt;zlib&lt;/code&gt;, you do:&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;fu&#34;&gt;nix:&lt;/span&gt;
  &lt;span class=&#34;fu&#34;&gt;packages:&lt;/span&gt;
  &lt;span class=&#34;kw&#34;&gt;-&lt;/span&gt; zlib&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will allow you to build projects without modifying your global system.&lt;/p&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/stack-cookbook-ai0adh03#item-q9wsa91k"/></entry><entry><id>d5ug4iib</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Loading the project into REPL</title><updated>2019-03-09T14:48:09Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;Loading the project into REPL&lt;/span&gt;

&lt;/h1&gt;&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# Load everything&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; repl

&lt;span class=&#34;co&#34;&gt;# Load a single target (library, testsuite, etc; get the list of targets &lt;/span&gt;
&lt;span class=&#34;co&#34;&gt;# with &#39;stack ide targets&#39;)&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; repl &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;target&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&#34;co&#34;&gt;# Load a single module&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; repl --no-load
&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt; :&lt;span class=&#34;ex&#34;&gt;l&lt;/span&gt; &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;module name&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/stack-cookbook-ai0adh03#item-d5ug4iib"/></entry><entry><id>kb2vt2gg</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Adding dependencies</title><updated>2019-03-09T14:47:30Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;Adding dependencies&lt;/span&gt;

&lt;/h1&gt;&lt;p&gt;To use a dependency that is available in the snapshot, add it to your &lt;code&gt;.cabal&lt;/code&gt; or &lt;code&gt;package.yaml&lt;/code&gt; file. Snapshot contents, including the exact package versions, are listed at &lt;code&gt;https://www.stackage.org/lts-XX.YY&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;library                &lt;span class=&#34;co&#34;&gt;-- In a .cabal file&lt;/span&gt;
  build&lt;span class=&#34;fu&#34;&gt;-&lt;/span&gt;depends&lt;span class=&#34;fu&#34;&gt;:&lt;/span&gt;
    aeson       &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;fu&#34;&gt;library:&lt;/span&gt;                &lt;span class=&#34;co&#34;&gt;# In a package.yaml file&lt;/span&gt;
  &lt;span class=&#34;fu&#34;&gt;dependencies:&lt;/span&gt;
    &lt;span class=&#34;kw&#34;&gt;-&lt;/span&gt; aeson&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To use a dependency that is &lt;em&gt;not&lt;/em&gt; in the snapshot, you also need to add it to &lt;code&gt;extra-deps&lt;/code&gt; in &lt;code&gt;stack.yaml&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;fu&#34;&gt;extra-deps:&lt;/span&gt;
  &lt;span class=&#34;co&#34;&gt;# From Hackage&lt;/span&gt;
  &lt;span class=&#34;kw&#34;&gt;-&lt;/span&gt; amazonka-core-1.6.0

  &lt;span class=&#34;co&#34;&gt;# From a Git / Mercurial repo (add &amp;quot;subdirs&amp;quot; if you want only certain&lt;/span&gt;
  &lt;span class=&#34;co&#34;&gt;# directories from the repo):&lt;/span&gt;
  &lt;span class=&#34;kw&#34;&gt;-&lt;/span&gt; &lt;span class=&#34;fu&#34;&gt;git:&lt;/span&gt; https://github.com/brendanhay/amazonka
    &lt;span class=&#34;fu&#34;&gt;commit:&lt;/span&gt; 9750d3d0bf4a079831c20efeb9ef372759895b48
    &lt;span class=&#34;fu&#34;&gt;subdirs:&lt;/span&gt; 
    &lt;span class=&#34;kw&#34;&gt;-&lt;/span&gt; core

  &lt;span class=&#34;co&#34;&gt;# From a directory&lt;/span&gt;
  &lt;span class=&#34;kw&#34;&gt;-&lt;/span&gt; ./amazonka/core

  &lt;span class=&#34;co&#34;&gt;# From an archive accessible by a URL (add &amp;quot;subdirs&amp;quot; if you want only&lt;/span&gt;
  &lt;span class=&#34;co&#34;&gt;# certain directories from the archive):&lt;/span&gt;
  &lt;span class=&#34;kw&#34;&gt;-&lt;/span&gt; &lt;span class=&#34;fu&#34;&gt;archive:&lt;/span&gt; https://github.com/brendanhay/amazonka/archive/1.6.0.tar.gz
    &lt;span class=&#34;fu&#34;&gt;subdirs:&lt;/span&gt;
    &lt;span class=&#34;kw&#34;&gt;-&lt;/span&gt; core
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;(Note: if a package isn&#39;t on Stackage, you can &lt;a href=&#34;https://github.com/commercialhaskell/stackage/blob/master/MAINTAINERS.md#adding-a-package&#34;&gt;add it there&lt;/a&gt;, though it works better when you&#39;re the actual package maintainer for that package.)&lt;/p&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/stack-cookbook-ai0adh03#item-kb2vt2gg"/></entry><entry><id>xww510b3</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Listing dependencies</title><updated>2019-03-09T14:24:43Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;Listing dependencies&lt;/span&gt;

&lt;/h1&gt;&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# List all dependencies, transitively&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; ls dependencies

&lt;span class=&#34;co&#34;&gt;# List test/bench dependencies too&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; ls dependencies --test --bench

&lt;span class=&#34;co&#34;&gt;# List licenses of all dependencies (useful for detecting scary GPL)&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; ls dependencies --license&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# List all dependency pairs (useful for figuring out what brings&lt;/span&gt;
&lt;span class=&#34;co&#34;&gt;# a particular dependency in)&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; dot --external&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/stack-cookbook-ai0adh03#item-xww510b3"/></entry><entry><id>h7dcfoax</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Building documentation</title><updated>2019-03-09T14:23:08Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;Building documentation&lt;/span&gt;

&lt;/h1&gt;&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# Build documentation&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; haddock --no-haddock-deps

&lt;span class=&#34;co&#34;&gt;# Build documentation for all dependencies, too (might take a long time&lt;/span&gt;
&lt;span class=&#34;co&#34;&gt;# if they all need to be recompiled)&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; haddock

&lt;span class=&#34;co&#34;&gt;# Open generated docs in a browser&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; haddock --open&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# Start a custom Hoogle server that knows all your local packages.&lt;/span&gt;
&lt;span class=&#34;co&#34;&gt;# Great for looking up documentation while offline. Server is located&lt;/span&gt;
&lt;span class=&#34;co&#34;&gt;# at http://localhost:8080/&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; hoogle -- serve -p 8080 --local&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/stack-cookbook-ai0adh03#item-h7dcfoax"/></entry><entry><id>e258sp2p</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Running tests</title><updated>2019-03-09T14:23:03Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;Running tests&lt;/span&gt;

&lt;/h1&gt;&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# Run all tests&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; test --fast

&lt;span class=&#34;co&#34;&gt;# Run only certain tests (hspec)&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; test --fast --ta=&lt;span class=&#34;st&#34;&gt;&amp;quot;-m &amp;lt;test name pattern&amp;gt;&amp;quot;&lt;/span&gt;

&lt;span class=&#34;co&#34;&gt;# Run only certain tests (tasty)&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; test --fast --ta=&lt;span class=&#34;st&#34;&gt;&amp;quot;-p &amp;lt;test name pattern&amp;gt;&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Tasty pattern documentation: &lt;a href=&#34;https://documentup.com/feuerbach/tasty#patterns&#34;&gt;https://documentup.com/feuerbach/tasty#patterns&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Hspec pattern documentation: &lt;a href=&#34;https://hspec.github.io/match.html&#34;&gt;https://hspec.github.io/match.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It&#39;s also possible to pass any other arguments to the testsuite with &lt;code&gt;--ta&lt;/code&gt;. Try &lt;code&gt;--ta=--help&lt;/code&gt; to see what arguments are supported by the test framework you&#39;re using.&lt;/p&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/stack-cookbook-ai0adh03#item-e258sp2p"/></entry><entry><id>j1ffxbz4</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Building a project</title><updated>2019-03-09T14:22:42Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;Building a project&lt;/span&gt;

&lt;/h1&gt;&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# Build for development (no optimizations; compiles tests but doesn&#39;t run them)&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; build --fast --test --no-run-tests

&lt;span class=&#34;co&#34;&gt;# Build for production (-O -Wall -Werror)&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; build --pedantic

&lt;span class=&#34;co&#34;&gt;# Build a single subproject&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; build &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;exe/lib name&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# Build and copy binaries into ~/.local/bin&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; install

&lt;span class=&#34;co&#34;&gt;# ...or into a directory&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; install --local-bin-path=&lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;dir&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;stack build&lt;/code&gt; builds the project. Most common flags that you&#39;ll need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;--test&lt;/code&gt;, &lt;code&gt;--bench&lt;/code&gt; – compile and run tests/benchmarks.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;--no-run-tests&lt;/code&gt;, &lt;code&gt;--no-run-benchmarks&lt;/code&gt; – don&#39;t run tests/benchmarks.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;--fast&lt;/code&gt; – compile without optimizations.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;--file-watch&lt;/code&gt; – automatically rebuild when you change files in the project. Very useful if you&#39;re not using &lt;code&gt;ghcid&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;--pedantic&lt;/code&gt; – compile with all warnings enabled, treating warnings as errors.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;--profile&lt;/code&gt; – build with profiling.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;--ghc-options=&amp;quot;...&amp;quot;&lt;/code&gt; – pass extra options to GHC.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/stack-cookbook-ai0adh03#item-j1ffxbz4"/></entry><entry><id>fvcy0xsa</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Converting an existing project to Stack</title><updated>2019-03-09T14:14:49Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;Converting an existing project to Stack&lt;/span&gt;

&lt;/h1&gt;&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# Create a stack.yaml file&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; init --resolver=lts-XX.YY

&lt;span class=&#34;co&#34;&gt;# Create a stack.yaml file and try to guess what snapshot to use&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; init

&lt;span class=&#34;co&#34;&gt;# Use cabal-install as a project creation wizard&lt;/span&gt;
&lt;span class=&#34;fu&#34;&gt;mkdir&lt;/span&gt; &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;project name&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;kw&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&#34;bu&#34;&gt;cd&lt;/span&gt; &lt;span class=&#34;st&#34;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&#34;va&#34;&gt;$_&lt;/span&gt;&lt;span class=&#34;st&#34;&gt;&amp;quot;&lt;/span&gt; &lt;span class=&#34;kw&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&#34;ex&#34;&gt;cabal&lt;/span&gt; init &lt;span class=&#34;kw&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; init&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;stack init&lt;/code&gt; creates a &lt;code&gt;stack.yaml&lt;/code&gt; file for a project with an existing &lt;code&gt;.cabal&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;It&#39;s best to use as few different resolvers as possible to save space on your hard drive. Pick a snapshot you like and then pass it with &lt;code&gt;--resolver=lts-XX.YY&lt;/code&gt;. Existing snapshots and GHC versions are cached in &lt;code&gt;~/.stack&lt;/code&gt;.&lt;/p&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/stack-cookbook-ai0adh03#item-fvcy0xsa"/></entry><entry><id>ohp99d7t</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Creating a project from a template</title><updated>2019-03-09T13:59:08Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;Creating a project from a template&lt;/span&gt;

&lt;/h1&gt;&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;# Create a directory and a project&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; new &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;project name&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;template name&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt; --resolver=lts-XX.YY

&lt;span class=&#34;co&#34;&gt;# Create a directory and a project, using the newest snapshot&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; new &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;project name&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;template name&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&#34;co&#34;&gt;# Create a project in the current directory&lt;/span&gt;
&lt;span class=&#34;ex&#34;&gt;stack&lt;/span&gt; new &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;project name&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;op&#34;&gt;&amp;lt;&lt;/span&gt;template name&lt;span class=&#34;op&#34;&gt;&amp;gt;&lt;/span&gt; --bare&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;stack new&lt;/code&gt; creates a directory and populates it with a template from GitHub. Some templates: &lt;a href=&#34;https://github.com/commercialhaskell/stack-templates&#34;&gt;commercialhaskell/stack-templates&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you don&#39;t know what template to use, try &lt;code&gt;simple-hpack&lt;/code&gt; – it creates a BSD-3 licensed executable with a &lt;code&gt;package.yaml&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;It&#39;s best to use as few different resolvers as possible to save space on your hard drive. Pick a snapshot you like and then pass it with &lt;code&gt;--resolver=lts-XX.YY&lt;/code&gt;. Existing snapshots and GHC versions are cached in &lt;code&gt;~/.stack&lt;/code&gt;.&lt;/p&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/stack-cookbook-ai0adh03#item-ohp99d7t"/></entry></feed>