Haskell Learners' Group (Session 1)
By Walker Malling and Richard Cook, 2018/4/4

A recap of what we talked about during the first meeting of the all-new Haskell Learners’ Group in Seattle


We went round the room to introduce ourselves and gauge the level of experience of each attendee.

What is Stack?

Modify your global Stack configuration

UPDATE: It turns out that this is not true (see this issue in GitHub). It is not currently possible to specify a default resolver globally. Instead, you’ll need to explicitly pass --resolver=lts-11.3 on the command line or edit your project-level stack.yaml files.

Create a new project

stack new hello-seattle simple

UPDATE: Again, you’ll need to explicitly specifier a resolver if the default is not appropriate. Since LTS 11.3 is the current default, this is OK for the time being. To lock to this version in the future:

stack new hello-seattle simple --resolver=lts-11.3

Build the project

stack build

This builds your project and creates the resulting binary in a subdirectory under the .stack-work directory in your project’s root. Typically, you’ll want to add .stack-work to your .gitignore file if you’re using Git version control for your project since you won’t want to check binaries in.

AWS Lambda and native binaries

Rambling aside by Richard

Note that, while AWS Lambda doesn’t directly advertise runtime support for Haskell programs, you can distribute native binaries. By default, Stack generates statically-linked binaries which can easily be bundled up and deployed to Lambda.

I (Richard) have written a series of blog posts on using Haskell to interact with AWS services (built on the really cool Amazonka family of Haskell packages. Note that Amazonka makes pretty heavy use of lenses which we’ll learn about later.


stack clean

Execute program

stack exec hello-seattle


To install a copy of your executable to a location on your system search path, i.e. somewhere on the PATH environment variable, for example at ~/.local/bin/hello-seattle in this case:

stack install hello-seattle

Build and run in one step

stack build --exec hello-seattle

View Stack paths

List all of Stack’s special paths:

stack path

Launch GHCi REPL

stack ghci
Command Description
:type Returns the type signature of the given expression
:kind Shows the kind of a given type
:info Returns general info about a given name
:!<cmd> Shell out to execute a command
:edit If you have a source file loaded, this will open your system default editor to the referenced line

This command will determine the appropriate version of GHC/GHCi to use based on your project’s stack.yaml or the global configuration file in effect. When run as part of a project, all the packages referenced in your .cabal file will also be available to import functions from.

Other Stack commands mentioned but not demonstrated

A brief look at our hello-seattle project

module Main where

main :: IO ()
main = do
  putStrLn "hello world"

Discussion of course materials and formats

We rounded out the evening by talking about what form future meetings of the learners’ group should take.