Scala port of the Vertigo compiler by Conal Elliott