Lesson 1: Introduction to case expressions

Contents
  • Conditionals
  • Reading type signatures
  • Branching patterns
  • Case expressions
  • Sum types
Video
  • 9 minutes
Tags
conditional case expression sum type pattern matching Bool

The first lesson takes a look at conditional if-then-else expressions in Haskell and compares them to expressions with different syntax: case expressions. Conditionals and case expressions serve a similar purpose; they both allow a function’s behavior to vary depending on the result of an expression. However, case expressions have some flexibility that if expressions do not have, namely allowing behavior to branch on values other than booleans.