Postlude

We have covered the basics and monads. There’s a lot more to functional programming and Haskell!

State Monad Transformer

newtype StateT s m a =
  StateT { runStateT :: s -> m (a, s) }

type State    s a = StateT  s          Identity a
type Parser     a = StateT  String     []       a
type NState   s a = StateT  s          []       a
type NState01 s a = StateT (s, StdGen) Maybe    a

Overview of Monoids, Foldable, and Traversable

Writer and Reader

newtype State  s   a  =  { runState  ::   s -> (a, s  ) }
newtype Reader env a  =  { runReader :: env ->  a       }
newtype Writer log a  =  { runWriter ::        (a, log) }

State s a    values produce an a… while also reading and “updating mutable state” of type s.

Reader env a values produce an a… while also accessing some (read-only) environment.

Writer log a values produce an a… plus a “log” (often a String or list but in general any Monoid).

Laziness and Seq

Mutable State (if you’re “overly attached” or actually require it)

Zippers

Lens: Lenses, Folds, and Traversals

Generalized Algebraic Datatypes (GADTs)

QuickCheck: Randomized Property-Based Testing

🎆 Fireworks, courtesy of Logan Quick! 🎆