Labs¶
Labs are in-class, hands-on sessions — mostly working directly in ghci, with the occasional file to edit. They're meant to be done live, ideally with a partner or grutor nearby to ask questions.
- Lab 1: Getting Connected and Running Haskell — connect to the CS 131 server from a terminal and through VS Code, open a terminal on the server, start
ghci, and create and load your first.hsfile. - Lab 2: GHCi Basics — your first real time in
ghci: run expressions, read what Haskell tells you, and practice predicting an output before you run it. Uses functions from Module 02.1 and 02.2 plus a few new ones (filter,reverse,show,sort). - Lab 3: Tuples, Stacks, and Currying — a
ghcisession on pairs, list-based stacks, and currying/uncurrying — mostly comparing multiple correct implementations of the same idea. - Lab 4: Boolean Expressions — completing
evalandprettyPrintfunctions for a small boolean-expression datatype, the same evaluator/formatter pattern that shows up again in Module 04.1/04.2. - Lab 5: Two Ways to Draw: Plotter Python and piq — writing and comparing two levels of a pen-plotter drawing language: raw five-command plotter Python, and
piq, a small language with loops and procedures that compiles down to it. - Lab 6: A First Look at Parsing piq — practicing the course's parser combinator library directly in
ghci, then writing a small, deliberately restricted slice of realpiqparsing before HW6 asks for the whole grammar. - Lab 7: From Higher-Order Functions to Monads — a staircase from higher-order functions and pointfree style through composition and
fmapto>>=, then one stack-calculator program rewritten three ways until the homemade combinator turns out to be a monad. - Lab 8: Lambda Calculus Encodings — writing
IsNil,Head, andTailfor tagged lists andPlus,Times, and Kleene's predecessor for Church numerals in thelcinterpreter, with the encodings HW 08 builds on.
Coming soon
Labs will be posted here as the semester develops. Each one will be linked from the schedule on the day it runs.