Created
August 10, 2017 06:32
-
-
Save anonymous/5accc12d5d05594adc086716fbb2258c to your computer and use it in GitHub Desktop.
the description for this gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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