Skip to content

Instantly share code, notes, and snippets.

@Lasering
Last active October 14, 2016 13:23
Show Gist options
  • Save Lasering/bd997ef0f0ffb9a030fca0c5f6f65f90 to your computer and use it in GitHub Desktop.
Save Lasering/bd997ef0f0ffb9a030fca0c5f6f65f90 to your computer and use it in GitHub Desktop.
sealed trait TaskComapped[L <: HList, M <: HList]
object TaskComapped{
implicit def nil: TaskComapped[HNil, HNil] = new TaskComapped[HNil, HNil]{}
implicit def cons[Head, Tail <: HList, ResultsTail <: HList](implicit tc: TaskComapped[Tail, ResultsTail]) =
new TaskComapped[Task[Head] :: Tail, Head :: ResultsTail]{}
}
abstract class Task[R](value: R) {
def destination: Int
}
implicit class hlist2Relation[DL <: HList, RL <: HList](dependencies: DL)(implicit ev: TaskComapped[DL, RL]) {
def dependenciesOf[R](f: RL => Task[R]) = println("something")
}
val a = new Task("abs") {
def destination: Int = 9
}
val aHList: ::[Task[String] {def destination: Int}, HNil] = a :: HNil
val aD = (a :: HNil) dependenciesOf { case s :: HNil =>
new Task(s.length) {
def destination: Int = 5
}
}
val b: Task[String] = new Task("abs") {
def destination: Int = 9
}
val bHList: ::[Task[String], HNil] = b :: HNil
val bD = (b :: HNil) dependenciesOf { case s :: HNil =>
new Task(s.length) {
def destination: Int = 5
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment