Skip to content

Instantly share code, notes, and snippets.

/post.scala
Created Aug 10, 2017

Embed
What would you like to do?
the description for this gist
type PrettyPrint[ScalaValue] = String
val interpretAsPrettyPrint = new Language[PrettyPrint] {
override def number(v: Int): PrettyPrint[Int] = s"($v)"
override def increment(a: PrettyPrint[Int]): PrettyPrint[Int] = s"(inc $a)"
override def add(a: PrettyPrint[Int], b: PrettyPrint[Int]): PrettyPrint[Int] = s"(+ $a $b)"
override def text(v: String): PrettyPrint[String] = s"[$v]"
override def toUpper(a: PrettyPrint[String]): PrettyPrint[String] = s"(toUpper $a)"
override def concat(a: PrettyPrint[String], b: PrettyPrint[String]): PrettyPrint[String] = s"(concat $a $b)"
override def toString(v: PrettyPrint[Int]): PrettyPrint[String] = s"(toString $v)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.