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. |
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. | |
uniform float waves; |
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
private def buildTypeAlias(api: TypingTransformApi)(monadTTpe: Type)(mtpe: TypeSymbol)(innerTpe: Type): (TypeSymbol, Tree) = { | |
val nm = c.fresh(monadTTpe.typeSymbol.name.decodedName.toString) | |
val tname = newTypeName(nm) | |
val termname = newTermName(nm) | |
val sym = newTypeSymbol(api.currentOwner, tname) | |
val tree = q"""{ | |
type $tname[T] = ${monadTTpe.typeSymbol}[${mtpe.typeSymbol}, T] | |
object $termname { | |
def apply[T](t: $mtpe[${innerTpe.typeSymbol}[T]]): $tname[T] = ${monadTTpe.typeSymbol.companion}.apply[${mtpe.typeSymbol}, 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
private def buildMonadTypeAlias(api: TypingTransformApi)(monadTTpe: Type)(mtpe: Type)(innerTpe: Type): (TypeSymbol, Tree) = { | |
val nm = c.fresh(monadTTpe.typeSymbol.name.decodedName.toString) | |
val tname = newTypeName(nm) | |
val termname = newTermName(nm) | |
val sym = newTypeSymbol(api.currentOwner, tname).setInfo(typeBounds(definitions.NothingTpe, definitions.AnyTpe)) | |
val tree = q"""{ | |
type $tname[T] = ${monadTTpe.typeSymbol}[${mtpe.typeSymbol}, T] | |
object $termname { | |
def apply[T](t: ${mtpe.typeSymbol}[${innerTpe.typeSymbol}[T]]): $tname[T] = ${monadTTpe.typeSymbol.companion}.apply[${mtpe.typeSymbol}, 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
// First I create this alias type tree | |
val aliasTypeTree = q"""{ | |
type $typeName[T] = ... | |
object $termName { | |
def apply[T](t: ...): $typeName[T] = ... | |
} | |
}""" | |
// I first try to use previous alias type in a block of code | |
val tree1 = q """ |
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> implicitly[MonadPlus[({ type m[A] = ListT[({ type l[B] = OptionT[Future, B] })#l, A] })#m]] | |
<console>:23: scalaz.this.ListT.listTMonadPlus is not a valid implicit value for scalaz.MonadPlus[[A]scalaz.ListT[[B]scalaz.OptionT[scala.concurrent.Future,B],A]] because: | |
hasMatchingSymbol reported error: polymorphic expression cannot be instantiated to expected type; | |
found : [F[_]]scalaz.MonadPlus[[α]scalaz.ListT[F,α]] | |
required: scalaz.MonadPlus[[A]scalaz.ListT[[B]scalaz.OptionT[scala.concurrent.Future,B],A]] | |
implicitly[MonadPlus[({ type m[A] = ListT[({ type l[B] = OptionT[Future, B] })#l, A] })#m]] | |
^ | |
<console>:23: error: could not find implicit value for parameter e: scalaz.MonadPlus[[A]scalaz.ListT[[B]scalaz.OptionT[scala.concurrent.Future,B],A]] | |
implicitly[MonadPlus[({ type m[A] = ListT[({ type l[B] = OptionT[Future, B] })#l, A] })#m]] |
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> val toto = 5; val tata = "chboing" | |
toto: Int = 5 | |
tata: String = chboing | |
scala> val qq = q"""{ "foo" : $toto, $tata : "bar" }""" | |
<console>:13: error: ';' expected but ',' found. | |
val qq = q"""{ "foo" : $toto, $tata : "bar" }""" |
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
/** A universally quantified value */ | |
trait Forall2[P[_, _]] { | |
def apply[A, B]: P[A, B] | |
} | |
object Forall2 extends Foralls2 | |
trait Foralls2 { | |
/** Universal quantification by doubly negating an existential. */ | |
type Not[A] = A => Nothing |
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
"ShapelessExt" should "try" in { | |
implicit class Rich[A](val a: A) { | |
def +[B](b: B)(implicit hm: HMonoid[A, B]) = hm.append(a, b) | |
} | |
// HList HMonoid | |
val s = (1 :: "string" :: HNil) + (true :: HNil) | |
s should equal (1 :: "string" :: true :: HNil) |
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
trait APointer[U, A] extends DepFn1[A] { type Out <: U} | |
implicit def HListAPointer[A] = new APointer[HList, A] { | |
type Out = A :: HNil | |
def apply(a: A) = a :: HNil | |
} | |
scala> val t: Int :: HNil = implicitly[APointer[HList, Int]].apply(1) | |
type mismatch; |