Setting up a native Haskell development environment

The homework assignments in this course use a Haskell build tool called Stack. If you want to set up a native Haskell development environment, your first step should be to install Stack. This is a good way to go, especially if you’re using Linux or macOS. (Windows users might have a better time using the dev container or using Codespaces; those alternatives are described below.)

All of the homework assignments in the course are structured as Stack projects. You can build them using the command stack build, run tests using stack test, and so on. Many more Stack commands are documented in the Stack user’s guide. Individual homework assignments will include information on the specific Stack commands you’ll need to run to do the homework.

You can also run stack ghci to start an interactive session with GHCi, in which Haskell expressions can be interactively evaluated. We’ll do a lot of playing in GHCi during lecture!

VS Code Dev Container

Another alternative to installing a native Haskell environment is to use the CSE114A VS Code dev container. This is a Docker container pre-configured with a Haskell environment (including Stack and everything else you need) that you can interact with directly from VS Code. The dev container is a good option if you’re having trouble setting up a native Haskell development environment for whatever reason, especially if you’re using VS Code and running Docker anyway. All of the homework assignments are already configured to use the dev container, though it’s not required.

See the CSE114A dev container documentation for instructions on how to use it.

For general information on VS Code dev containers, see the VS Code documentation.

GitHub Codespaces

Yet another alternative is to set up your development environment using GitHub’s Codespaces. A Codespace is just like a dev container, but instead of running on your local machine, it runs in the cloud.

To create a new Codespace, go to the repository created after you accept an assignment. Click on the green <> Code button and select the Codespaces tab. Finally click the green Create codespace on main button.

A new tab will open and GitHub will begin building your codespace based on the CSE114A dev container. Once it is complete, a web-based VS Code interface will display with your repository folder open. Notice there is a terminal on the right (or you can open one using the Terminal menu).

Some VS Code extensions are not compatible with the web interface. If you would like to open the codespace in the VS Code desktop app, click on the green >< Codespaces button at the bottom left, and select Open in VS Code from the pull-down menu that appears at the top.

Textbooks

There are no required textbooks for this course, but using one or more of the following textbooks to expand your understanding of course topics is highly recommended. In particular, these textbooks are good sources of example problems to test your understanding of course concepts. When a free online copy is available (either a preprint or an ebook via the UCSC library), I’ve noted it below. More ebooks may become available through the library soon.

  • Programming Languages: Application and Interpretation (third edition) by Shriram Krishnamurthi. Available free online.

  • Learn You a Haskell for Great Good by Miran Lipovača. Available free online.

  • An Introduction to Functional Programming Through Lambda Calculus by Greg Michaelson. Available free online.

  • Thinking Functionally with Haskell by Richard Bird. Available online (free via library).

  • Programming in Haskell (second edition) by Graham Hutton.

  • Real World Haskell by Bryan O’Sullivan. Available free online.

Exams from previous editions of the course

You might find these useful for studying.