Pattern-driven Programming in Scala