2010-06-01 14:38:56 +02:00
|
|
|
/* sbt -- Simple Build Tool
|
|
|
|
|
* Copyright 2010 Mark Harrah
|
|
|
|
|
*/
|
2010-05-31 03:14:18 +02:00
|
|
|
package sbt
|
|
|
|
|
|
|
|
|
|
import Node._
|
|
|
|
|
import Types._
|
|
|
|
|
|
|
|
|
|
trait Node[A[_], T]
|
|
|
|
|
{
|
2010-06-01 14:38:56 +02:00
|
|
|
type Inputs <: MList[A]
|
2010-05-31 03:14:18 +02:00
|
|
|
type Results <: Inputs#Map[Result]
|
|
|
|
|
|
2010-06-01 14:38:56 +02:00
|
|
|
val inputs: Inputs
|
2010-05-31 03:14:18 +02:00
|
|
|
def unitDependencies: Iterable[A[_]]
|
|
|
|
|
|
|
|
|
|
def work(results: Results, units: Iterable[Incomplete]): Either[A[T], T]
|
|
|
|
|
}
|
2010-06-01 14:38:56 +02:00
|
|
|
|
2010-05-31 03:14:18 +02:00
|
|
|
object Node
|
|
|
|
|
{
|
|
|
|
|
def pure[T](f: => T): PureNode[T]= map[Id, T, MNil](MNil, Nil)((_,_) => f)
|
|
|
|
|
|
2010-06-01 14:38:56 +02:00
|
|
|
def map[A[_], T, Inputs0 <: MList[A]](inputs0: Inputs0, deps0: Iterable[A[_]])(work0: (Inputs0#Map[Result], Iterable[Incomplete]) => T):
|
2010-05-31 03:14:18 +02:00
|
|
|
Node[A,T] { type Inputs = Inputs0; type Results = Inputs0#Map[Result] } =
|
2010-06-01 14:38:56 +02:00
|
|
|
new Node[A,T] {
|
|
|
|
|
type Inputs = Inputs0
|
|
|
|
|
type Results = Inputs0#Map[Result]
|
|
|
|
|
val inputs = inputs0
|
|
|
|
|
def unitDependencies = deps0
|
|
|
|
|
def work(results: Results, units: Iterable[Incomplete]) = Right(work0(results, units))
|
|
|
|
|
}
|
2010-05-31 03:14:18 +02:00
|
|
|
|
|
|
|
|
type PureNode[T] = Node[Id, T] { type Inputs = MNil; type Results = MNil }
|
|
|
|
|
}
|