Skip to content

Instantly share code, notes, and snippets.

TiarkRompf / AutoDiff.scala
Last active January 11, 2020 07:37
Reverse-mode automatic differentiation
package autodiff
import org.scalatest._
import org.scalatest.Assertions._
import scala.collection.mutable._
class AutoDiffSpec extends FunSuite {
// computation graph (list of nodes)
TiarkRompf / CollapsingTowers.scala
Last active July 30, 2022 21:19
compilation by interpreting* staged interpreters
/* collapsing multiple levels of interpreters */
object TestMeta3 {
abstract class Exp
case class Lit(n:Int) extends Exp
case class Sym(s:String) extends Exp
case class Var(n:Int) extends Exp
case class App(e1:Exp, e2:Exp) extends Exp
case class Lam(e:Exp) extends Exp
TiarkRompf / GenericLifiting.scala
Last active November 30, 2017 16:28
generic class lifting and method forwarders
import language.experimental.macros
import language.dynamics
import scala.reflect.macros._
case class Rep[+T](x:String)
implicit def anyToRep[T](x:T) = new Rep[T](x.toString)
class ShouldLift[T]
TiarkRompf / FixingQuasiquotes.scala
Last active November 30, 2017 16:28
reflect/reify quasi-quotes
package test1
fixing quasi-quotes
when writing a program using quasi-quotation:
val x = c"foo()"