diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-05 16:19:30 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-05 16:19:30 -0800 |
commit | 427134c820f4c9a9e281ba3607ab4879c6185613 (patch) | |
tree | f53529f14234e00a2ac41c3275d4898298e74957 /core/src/main/scala/forge/define/Target.scala | |
parent | 44bd42587532755439fcdc175eb95604966bbea8 (diff) | |
download | mill-427134c820f4c9a9e281ba3607ab4879c6185613.tar.gz mill-427134c820f4c9a9e281ba3607ab4879c6185613.tar.bz2 mill-427134c820f4c9a9e281ba3607ab4879c6185613.zip |
Break out `Cacher.scala` from `Applicative.scala` to fully separate the gnarly macros
Diffstat (limited to 'core/src/main/scala/forge/define/Target.scala')
-rw-r--r-- | core/src/main/scala/forge/define/Target.scala | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/core/src/main/scala/forge/define/Target.scala b/core/src/main/scala/forge/define/Target.scala index b30db434..1d7a49f1 100644 --- a/core/src/main/scala/forge/define/Target.scala +++ b/core/src/main/scala/forge/define/Target.scala @@ -7,6 +7,7 @@ import forge.util.{Args, JsonFormatters} import play.api.libs.json.{Format, Json} import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context abstract class Target[T] extends Target.Ops[T] with Applyable[T]{ /** @@ -28,14 +29,21 @@ abstract class Target[T] extends Target.Ops[T] with Applyable[T]{ object Target extends Applicative.Applyer[Target, Target]{ def underlying[A](v: Target[A]) = v - type Cacher = Applicative.Cacher[Target[_]] + type Cacher = forge.define.Cacher[Target[_]] class Target0[T](t: T) extends Target[T]{ lazy val t0 = t val inputs = Nil def evaluate(args: Args) = t0 } - def apply[T](t: Target[T]): Target[T] = macro Applicative.impl0[Target, T] - def apply[T](t: T): Target[T] = macro Applicative.impl[Target, T] + def apply[T](t: Target[T]): Target[T] = macro forge.define.Cacher.impl0[Target, T] + def apply[T](t: T): Target[T] = macro impl[Target, T] + def impl[M[_], T: c.WeakTypeTag](c: Context) + (t: c.Expr[T]) + (implicit tt: c.WeakTypeTag[M[_]]): c.Expr[M[T]] = { + forge.define.Cacher.wrapCached(c)( + Applicative.impl(c)(t) + ) + } abstract class Ops[T]{ this: Target[T] => def map[V](f: T => V) = new Target.Mapped(this, f) |