Skip to content

Instantly share code, notes, and snippets.

@boggle
Created January 29, 2013 18:16
Show Gist options
  • Save boggle/4666313 to your computer and use it in GitHub Desktop.
Save boggle/4666313 to your computer and use it in GitHub Desktop.
Solving AST typing riddles
trait Rewriter[T] extends {
def rewrite[X <: T](a: Rewritable[X]): Rewritable[X]
}
trait Rewritable[T] {
self: T with Rewritable[T] =>
def rewrite(r: Rewriter[T]): T = r.rewrite[T](self).reveal
def reveal: T = self
}
class A extends Rewritable[A]
class B extends A with Rewritable[B]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment