Lesson 2: Case expressions practice

  • The goal
  • An anagram checker
  • Word validator
  • Validate first, then compare
  • Interactive program
  • 14 minutes
case expression sum type pattern matching Maybe IO

This lesson presents an extended example of using case expressions. In particular, we look carefully at an example that pattern matches on Maybe values, since the rest of the course assumes you understand that well. Our example code checks two String inputs to see if they are anagrams of one another. Additionally, we write a main executable that asks for and accepts user inputs in the REPL and uses the anagram-checking function on those inputs.