Skip to content

Instantly share code, notes, and snippets.

View joroKr21's full-sized avatar
🏠
Working from home

Georgi Krastev joroKr21

🏠
Working from home
View GitHub Profile
@joroKr21
joroKr21 / typelevelcps.scala
Created June 7, 2018 20:23 — forked from milessabin/typelevelcps.scala
Using type level continuation passing style to rewrite a whitebox macro (which relies on fundep materialization) as a blackbox macro
import scala.language.higherKinds
// Whitebox ...
trait Schema[T, R] {
def conv(t: T): R
}
object Schema {
// Whitebox macro: R is computed from T
implicit def mkSchema[T, R]: Schema[T, R] = ??? // macro ...
sealed abstract class SingletonOf[A, +B] {
}
object SingletonOf {
}
type <::[A, +B] = SingletonOf[A, B]
def single[A <: Singleton](a: A): SingletonOf[A, A] =
new SingletonOf[A, A] { }