From bfa3a996e9d8f48df4779f0d065f8ef36fd7127e Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Tue, 25 Jan 2011 22:20:05 -0500 Subject: [PATCH] simplify InputTask and provide InputKey factory methods --- main/Structure.scala | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/main/Structure.scala b/main/Structure.scala index a6e959733..24fee0308 100644 --- a/main/Structure.scala +++ b/main/Structure.scala @@ -14,13 +14,11 @@ package sbt import java.net.URI sealed trait InputTask[T] { - type S - def parser: Parser[S] - def apply(s: S): Task[T] + def parser: Parser[Task[T]] } object InputTask { - def apply[I,T](p: Parser[I], c: I => Task[T]): InputTask[T] { type S = I } = - new InputTask[T] { type S = I; def parser = p; def apply(s: I) = c(s) } + def apply[T](p: Parser[Task[T]]): InputTask[T] = new InputTask[T] { def parser = p } + def apply[I,T](p: Parser[I], c: I => Task[T]): InputTask[T] = apply(p map c) } sealed trait Scoped { def scope: Scope } @@ -209,6 +207,14 @@ object Scoped // private[this] val hcHead = new ( ({type l[t] = t :+: _})#l ~> Id ) { def apply[T](hc: t :+: _): t = hc.head } } +object InputKey +{ + def apply[T](label: String): InputKey[T] = + apply( AttributeKey[InputTask[T]](label) ) + + def apply[T](akey: AttributeKey[InputTask[T]]): InputKey[T] = + new InputKey[T](akey) +} object TaskKey { def apply[T](label: String): TaskKey[T] =