Typesafe: Is there any better way to write this code? - Theo's Typesafe Cult