Skip to content

Instantly share code, notes, and snippets.

@TiarkRompf
TiarkRompf / AutoDiff.scala
Last active Jan 11, 2020
Reverse-mode automatic differentiation
View AutoDiff.scala
package autodiff
import org.scalatest._
import org.scalatest.Assertions._
import scala.collection.mutable._
class AutoDiffSpec extends FunSuite {
// computation graph (list of nodes)
@TiarkRompf
TiarkRompf / CollapsingTowers.scala
Last active Dec 7, 2018
compilation by interpreting* staged interpreters
View CollapsingTowers.scala
/* 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
TiarkRompf / GenericLifiting.scala
Last active Nov 30, 2017
generic class lifting and method forwarders
View GenericLifiting.scala
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
TiarkRompf / FixingQuasiquotes.scala
Last active Nov 30, 2017
reflect/reify quasi-quotes
View FixingQuasiquotes.scala
package test1
/*
======================================================================
fixing quasi-quotes
======================================================================
when writing a program using quasi-quotation:
val x = c"foo()"