/hutton

Graham Hutton's Programming in Haskell (2016) - examples and exercises

Primary LanguageHaskellBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Graham Hutton's Programming in Haskell

This repository contains all my work, notes, and in-book examples from Graham Hutton's Programming in Haskell.

I began working in this book during my mini-batch at the Recurse Center in February 2020. I continued working in it over the following weeks, but also spent time on other projects, including beginning to work through HPFP (Haskell Programming from First Principles).

The Code

Lives in src/ folder.

chapter 1: Introduction

  • Functions, Functional Programming
  • Quicksort, sequencing actions

chapter 2: First Steps

  • GHC, GHCi, a quick tour of the Standard Prelude

chapter 3: Types and Classes

  • A quick tour of commonly used built-in types, Lists, and Tuples
  • function type signatures, currying, polymorphic types, class constraints
  • basic classes: Eq, Ord, Show, Read, Num, Integral, Fractional

chapter 4: Defining Functions

  • if-then-else, guards
  • pattern matching, also on tuples, also on lists
  • lambda expressions
  • operator sections; partially applied functions

chapter 5: List Comprehensions

  • generators, guards
  • zip function
  • String comprehensions
  • The Ceasar Cipher: extended example

chapter 6

chapter 7

chapter 8: Declaring Types and Classes

  • type, data, and newtype declarations
  • recursive types
  • class and instance declarations
  • Tautology checker: extended example

chapter 9

chapter 10: Interactive Programming

  • IO type, IO actions, do notation
  • examples of building up primitive actions (included in Standard Prelude) from just three basic IO actions: getChar, putChar, and return
  • extended examples:
    • Hangman
    • Nim
    • Game of Life

Summary

  • completed: chapters: 1, 2, 3, 4, 5, 8, 10
  • on deck:
    • chapter 6
    • chapter 7
    • chapter 10 :: Optional: exercise 6: I want to do this exercise and add it to hangman!
    • chapter 12 :: exercises 1-8.