Slide 35
Slide 35 text
35 / 43
https://gist.github.com/iTakeshi/f3aba5bb319693eef301923bc00755e1
Generation 3: Standard Syntax
package object macros {
trait Universe {
type Term
def IfApply(cnd: Term, thn: Term, els: Term): Term
def IfUnapply(term: Term): Option[(Term, Term, Term)]
}
val universe: Universe = ???
type Term = universe.Term
object TermIf {
def apply(cnd: Term, thn: Term, els: Term) = universe.IfApply(cnd, thn, els)
def unapply(term: Term) = universe.IfUnapply(term)
}
}
def invert(term: macros.Term): macros.Term = term match {
case macros.TermIf(c, t, e) => macros.TermIf(c, e, t)
case stat => stat
}