Index
Blog

case Syntax Error

I have been systematically making an error when writing case expressions on the board in class. Specifically, I’ve been using this syntax:

case e of a in
x = b
y = c
z = d


Haskell requires using a guard syntax rather than an equal syntax in case expressions. The above should be:

case e of a in
x -> b
y -> c
z -> d


Use -> instead of = and everything will be fine.

Sorry about that! The code in the online notes is correct.