Homework for Functional Programming in Scala course -- in Haskell