copy paste some awesome patterns from the Scala compiler
remove failed monadic attempt