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 play.api.libs.json._ | |
import play.api.libs.functional.syntax._ | |
sealed trait Parent { | |
val typ: String | |
} | |
case class Foo(blabla: Long, override val typ: String = "foo") extends Parent |
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
def task = Task.async{ cb: (Throwable \/ Int => Unit) => | |
try { | |
cb(right(42)) | |
} catch { case t:Throwable => cb(left(t))} } | |
def repeat(nb: Int) = { | |
def step(i: Int, c: Task[Int]): Task[Int] = { | |
if(i<nb) c.flatMap{ _ => step(i+1, task) } | |
else c | |
} |
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 java.net.InetSocketAddress | |
import scalaz.{-\/, \/, \/-} | |
import scalaz.concurrent.Task | |
import scalaz.stream._ | |
import scala.concurrent.duration._ | |
import ReceiveY._ | |
import scala.concurrent.SyncVar | |
object Server { |
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 Process._ | |
import java.net.InetSocketAddress | |
import scala.Some | |
import scala.concurrent.SyncVar | |
import scala.util.Random | |
import scalaz.-\/ | |
import scalaz.\/ | |
import scalaz.\/- | |
import scalaz.concurrent.Task | |
import scala.concurrent.duration._ |
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
// I have a macro | |
def macmac[M[_], T] = macro macmacImpl | |
def macmacImpl[M[_], T: c.WeakTypeTag](c: Context) | |
(body: c.Expr[T]) | |
(implicit mw: c.WeakTypeTag[M[_]]): c.Expr[M[T]] | |
// somewhere in the macro, it's calling this function | |
def myFun[M[_], T](block: Tree)(mType: WeakTypeTag[M[_]], tType: WeakTypeTag[T]): Tree = { |
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 scala.reflect.macros.Context | |
import scala.reflect.api.Universe | |
object Foo { | |
def doit[T](t: T) = ??? | |
def bar[T](body: T): Option[T] = macro barImpl[T] | |
def barImpl[T: c.WeakTypeTag](c: Context)(body: c.Expr[T]): c.Expr[Option[T]] = { | |
import c.universe._, c.internal._, decorators._, Flag._ |
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
//I have a type with 2 types params | |
class Toto[M[_], T] | |
// I make a Monad of Future of it using lambda-type | |
implicit val TotoMonad = Monad[({ type l[T] = Toto[Future, T]})#l]{...} | |
// then in my macro I want to create a type alias to { type l[T] = Toto[Future, T]})#l] and call the implicit monad | |
val mType: Type = ... | |
val sym = newTypeSymbol(api.currentOwner, "FooToto") |
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
val rhs = api.typecheck(q"type $l[T] = _root_.scalaz.OptionT[scala.concurrent.Future, T]") | |
println("RHS:" + rhs) | |
// gives | |
RHS:type Tata[T] = scalaz.OptionT[scala.concurrent.Future,<error>] | |
// and my global macro then fails with (even if I don't put rhs in my tree) | |
[error] not found: type 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
#ifdef GL_ES | |
precision highp float; | |
#endif | |
uniform sampler2D from, to; | |
uniform float progress; | |
uniform vec2 resolution; | |
// default a = 4 | |
uniform float a; | |
// default b = 1 |
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
#ifdef GL_ES | |
precision highp float; | |
#endif | |
uniform sampler2D from, to; | |
uniform float progress; | |
uniform vec2 resolution; | |
// default amplitude = 1.0 | |
uniform float amplitude; | |
// default waves = 30. |
OlderNewer