use pattern matching rather than when

Rather than having multiple equality/inequality tests in a guard clause, you can let the pattern-matching do the heavy lifting.

Whether you *want* to show this is another question.