Appendices: Projects, Interview Questions, Cheat Sheet & Study Plan
Capstone projects, interview questions, a Haskell cheat sheet, Haskell for imperative developers, and resources with a study plan.
Appendix A: Capstone Projects
Beginner: Command-Line Calculator. Parse arithmetic expressions with a hand-written parser combinator library (Module 27), evaluate with Either errors, and run a REPL loop.
Beginner: Text Statistics Tool. Word frequencies with Data.Map, Text, optparse-applicative options, sorted output.
Intermediate: To-Do App with Persistence. ADTs for commands, JSON storage with aeson, ReaderT config, Hspec + QuickCheck tests.
Intermediate: Bank Account Simulator. STM-based accounts, concurrent transfers with async, invariants checked with property tests.
Intermediate: Markdown-to-HTML Converter. A Megaparsec parser for a Markdown subset, an AST, an HTML renderer with lucid, and golden tests.
Intermediate: Game of Life. Pure simulation with Data.Set, a terminal UI with brick, and a comonadic implementation as a stretch goal.
Advanced: Typed Interpreter. A small language with a GADT-typed AST, a type checker from untyped to typed AST, an evaluator, and a REPL.
Advanced: REST API with Servant + PostgreSQL. CRUD, authentication (servant-auth/JWT), hasql or persistent, a ReaderT app monad, OpenAPI docs, Docker deployment.
Advanced: Concurrent Web Crawler. http-client + async with bounded concurrency (STM queue), HTML parsing (tagsoup/scalpel), politeness delays, conduit streaming.
Advanced: Key-Value Store with Free Monad DSL. Pure and IO interpreters, an effectful version, a TCP server with network, and property-based model testing.
Systems: FFI Binding. Wrap a C library (e.g., SQLite or zlib) with safe ForeignPtr resource management and a pure API.
Open Source: Publish to Hackage. A documented library with Haddock, doctests, CI across GHC versions, and a Hackage release.
Appendix B: Interview Questions
What do purity and referential transparency mean? Why are they useful?
What is lazy evaluation? Give advantages and pitfalls (space leaks).
What's the difference between Int and Integer? div vs quot?
What is currying? What is partial application?
Explain $, ., and point-free style.
Explain pattern matching, guards, where, let, and case.
Why are head and fromJust considered dangerous? What are the alternatives?
foldr vs foldl vs foldl'? When can foldr work on infinite lists?
What are algebraic data types? What does "make illegal states unrepresentable" mean?
type vs newtype vs data?
Type Classes and Abstractions What are type classes? How do they differ from OOP interfaces?
What are Semigroup and Monoid? Give examples and their laws.
Explain Functor, Applicative, and Monad with examples and laws.
When can you use Applicative but not Monad? Why does it matter?
What do Foldable and Traversable provide? What does traverse do?
What is do-notation desugared into?
How do Maybe, Either, List, State, Reader, and Writer behave as monads?
What are monad transformers? Why does the order of a stack matter?
What is mtl-style programming? What is the ReaderT pattern?
What is IO? How does Haskell keep effects out of pure code?
What are WHNF and NF? What do seq, deepseq, and bang patterns do?
How does the ST monad provide a pure interface to mutation (rank-2 types)?
Explain MVar vs STM. What do retry and orElse do?
What are GADTs? Give a use case.
What are type families? Open vs closed? Associated types?
What is DataKinds? Give an example of type-level safety.
What are rank-N types and existential types?
What are lenses? Lens vs prism vs traversal?
What are free monads? What is tagless final? What are effect systems?
What is GHC Core? How does GHC optimize (inlining, specialization, fusion, strictness analysis)?
How do you diagnose a space leak or a performance problem?
What is property-based testing? What is shrinking?
Implement map, filter, and reverse with foldr.
Write a Functor, Foldable, and Traversable instance for a binary tree.
Implement a parser combinator library and parse arithmetic expressions.
Implement the State monad from scratch (newtype, Functor/Applicative/Monad instances).
Write a function that returns all permutations of a list.
Solve N-Queens using the list monad.
Write a concurrent bank transfer with STM that never goes negative.
Write QuickCheck properties for a sorting function.
Appendix C: Haskell Cheat Sheet
-- ===== Basics =====
x :: Int; x = 42 -- binding with a signature
f :: Int -> Int -> Int; f a b = a + b
g = \x -> x * 2 -- lambda
h = (+ 1) . (* 2) -- composition
r = f 1 $ 2 + 3 -- $ application
if c then a else b; case v of { p1 -> e1; _ -> e2 }; let y = 1 in y + 1
fn x | x > 0 = "pos" | otherwise = "non-pos" where helper = 1
-- ===== Lists =====
[1, 2, 3]; 1 : [2, 3]; [1 .. 10]; [x * 2 | x <- xs, even x]; head/tail/take/drop/zip/zipWith
map f xs; filter p xs; foldr f z xs; foldl' f z xs; sum; length; reverse; concatMap; replicate
-- ===== Types =====
data Shape = Circle Double | Rect Double Double deriving (Show, Eq)
data P = P {name :: String, age :: Int}; p {age = 31}
newtype Id = Id Int; type Name = String
class C a where m :: a -> String; instance C Int where m = show
-- ===== Maybe / Either =====
Just 1; Nothing; maybe d f m; fromMaybe d m; Left "err"; Right 1; either f g e
-- ===== Functor / Applicative / Monad =====
fmap f x; f <$> x; pure x; f <$> a <*> b; m >>= k; do { x <- m; let y = f x; pure y }
traverse f xs; sequenceA; mapM_; forM_; when; unless; replicateM; foldM
-- ===== IO =====
m
…ghci :t expr :i Name :k Type :l File.hs :r :doc name :set -XExt
cabal init cabal build cabal run cabal test cabal repl cabal bench stack build hlint . ormolu -i src/*.hsAppendix D: Haskell for Imperative Developers
New bindings; State monad; IORef/STRef when truly needed for/while loops
Recursion, map/filter/foldr, forM_, replicateM_ Exceptions for errors
Either e a, ExceptT; throwIO for truly exceptional IO cases Classes with state and methods
Data types + functions; records of functions; modules for encapsulation
Composition, type classes with superclasses, sum types Generics (List<T>) Parametric polymorphism ([a])
Function arguments, ReaderT env, records of functions, effect systems Lazy lists, streaming libraries Threads + locks Green threads + STM / MVar / async Null checks everywhere
Pattern matching on Maybe (the compiler forces you to handle Nothing) void methods IO () actions Record fields, update syntax, lenses
Design patterns (Strategy, Visitor, Builder) Higher-order functions, pattern matching/folds, functions and Monoids Key gotchas:
There are no statements, only expressions; if requires else.
return doesn't exit a function; it just wraps a value in a monad.
= defines, it doesn't assign; x = x + 1 is an infinite loop (recursive definition).
Function application is whitespace; f(x, y) passes one tuple argument.
Numeric types don't convert automatically (fromIntegral).
Appendix E: Resources and Study Plan
Official and Online haskell.org (downloads, documentation), GHC User's Guide, Hackage, Hoogle, Stackage
Haskell MOOC (University of Helsinki, free), CIS 194 (UPenn course, free), Learn You a Haskell for Great Good! (free online), Real World Haskell (free online, dated)
Haskell Wiki, Typeclassopedia, What I Wish I Knew When Learning Haskell (Stephen Diehl), Haskell Weekly newsletter, Haskell Discourse
*Haskell Programming from First Principles* (Christopher Allen & Julie Moronuki): comprehensive beginner book
*Programming in Haskell* (Graham Hutton): concise and rigorous
*Get Programming with Haskell* (Will Kurt) *Effective Haskell* (Rebecca Skinner)
*Thinking Functionally with Haskell* (Richard Bird) *Parallel and Concurrent Programming in Haskell* (Simon Marlow): free online *Haskell in Depth* (Vitaly Bragilevsky) *Production Haskell* (Matt Parsons)
*Thinking with Types* (Sandy Maguire): type-level programming *Optics by Example* (Chris Penner) *Algebra-Driven Design* (Sandy Maguire)
*Category Theory for Programmers* (Bartosz Milewski) Haskell Discourse, r/haskell, the Haskell Foundation, Functional Programming Slack/Discord, Libera.Chat #haskell, ZuriHac, Haskell Symposium (ICFP), Haskell eXchange, local FP meetups 13-Week Study Plan Setup, GHCi, expressions, functions
Lists, pattern matching, recursion, higher-order functions Types, ADTs, records, type classes Maybe/Either, folds, modules and cabal Semigroup/Monoid, Functor, Applicative Monad, Foldable/Traversable, IO
Laziness, errors and exceptions, data structures Reader/Writer/State, transformers, parsing, JSON and CLIs Concurrency, STM, async, parallelism
Extensions, kinds, rank-N/existentials, GADTs, type families
DataKinds, deriving/generics, linear types, lenses, free monads/effects
Category theory, streaming, Template Haskell, testing, performance 48–53 + Capstone
FFI, web, databases, architecture, deployment, internals Final tip: Embrace the types. Let the compiler guide you with typed holes and -Wall. Master ADTs, pattern matching, folds, and Functor → Applicative → Monad, and the rest of Haskell becomes a series of satisfying "aha" moments. Write small programs often, read other people's code on Hackage, and enjoy the journey to "if it compiles, it works". Happy hacking! λ