Last active
September 6, 2017 17:01
-
-
Save esarbe/bd63911111dc17d03fd4f0584aa6c9bf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
object Main { | |
trait Language { | |
type F[X] | |
def num(i: Int): F[Int] | |
def add(l: F[Int], r: F[Int]): F[Int] | |
} | |
def expression(adder: Language) = { | |
import adder._ | |
add(num(1), num(2)) | |
} | |
val idLanguage = new Language { | |
type F[X] = X | |
def add(l: Int, r: Int): Int = l + r | |
def num(i: Int): Int = i | |
} | |
def main(args: Array[String]): Unit = { | |
println(expression(idLanguage)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment