This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> :paste | |
// Entering paste mode (ctrl-D to finish) | |
import scala.language.dynamics | |
import scala.language.experimental.macros | |
import scala.reflect.macros.whitebox | |
object implicitly extends Dynamic { | |
def apply[T](implicit t: T): T {} = t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import MyFuncMacro.myfunc | |
object MyFuncExample { | |
def main(args: Array[String]) { | |
val x: MyFunc[Int, Int] = myfunc { a: Int => a } | |
println(x) | |
println(x(42)) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> def foo[A, B, C](a: SNat[A], b: SNat[B], c: SNat[C])(implicit ssum: SSum[A, B, C]) = ssum | |
foo: [A, B, C](a: shapeless.SNat[A], b: shapeless.SNat[B], c: shapeless.SNat[C])(implicit ssum: shapeless.SSum[A,B,C])shapeless.SSum[A,B,C] | |
scala> foo(2, 3, 5) | |
res0: shapeless.SSum[Int(2),Int(3),Int(5)] = $anon$1@53d76e96 | |
scala> foo(2, 3, 7) | |
<console>:15: error: could not find implicit value for parameter ssum: shapeless.SSum[Int(2),Int(3),Int(7)] | |
foo(2, 3, 7) | |
^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object test { | |
trait M[X[_]] { | |
def map[A, B](a: X[A])(f: A => B): X[B] | |
} | |
trait Parsers { | |
trait Parser[Y] { | |
def map[B](f: Y => B): Parser[B] = null | |
} | |
} |
NewerOlder