Notes (HPFP 13/31): Building Projects

13 Building Projects

Since I’m building these projects on NixOS, I have to modify how to build with stack by putting the following shell.nix file in the project:

with (import <nixpkgs> {});

haskell.lib.buildStackProject {
  inherit ghc;
  name = "myEnv";
  buildInputs = [ zlib ];
  buildPhase = ''
    export LANG=en_US.UTF-8

and then running stack with the --nix flag, or enabling nix in the stack.yaml (or globally in ~/.stack/config.yaml) with

  enable: true

13.6 More on importing modules

Imtermission: Check your understanding

  1. forever, when
  2. Data.Bits, Database.Blacktip.Types
  3. Types for blacktip’s database

Chapter Exercises

Hangman game logic

See my hangman project on GitHub

I debated whether or not to include code snippets of full-fledged stack projects in this document. I’ve decided against it. It’s one thing to include self-contained modules as question answers, but if I were to, for example, include the Main.hs file for the hangman project here, there’d be some implicit dependencies like dict.txt and hangman.cabal, and if the past 524 pages of this book have taught me anything, implicit dependencies are bad news.

Upon further reflection, I’ve decided to axe essentially all code snippets from my notes. Code is much better in a type-checked source file than in a markdown file where it can diverge from it’s reference. I may add the snippets back if I figure out a clever way to get hakyll to auto-include them. For now I’ll just add links to the files on Github.

Modifying code

  1. see CipherIO.hs
  2. see ExitSuccess.hs
  3. see ExitSuccess.hs
  4. see Person.hs

13.15 Follow-up resources

  1. Stack
  2. How I Start: Haskell
  3. Cabal FAQ
  4. Cabal user’s guide
  5. A Gentle Introduction to Haskell, Modules chapter.