WIP of tupler update.
This commit is contained in:
parent
35a04d2651
commit
23212dfde8
@ -15,6 +15,7 @@ import Scalaz._
|
||||
import shapeless._
|
||||
import shapeless.syntax._
|
||||
import shapeless.ops.hlist._
|
||||
import shapeless.ops.function._
|
||||
|
||||
import scalafx.beans.property.ObjectProperty
|
||||
import scalafx.beans.value.ObservableValue
|
||||
@ -32,38 +33,6 @@ class ObservableTupler
|
||||
tupler: Tupler.Aux[HLParams, TParams],
|
||||
lister: ToList[HLObs, Observable[_]]) {
|
||||
|
||||
def ap[O, P, Appended <: HList]
|
||||
(f: ObservableValue[O, P])
|
||||
(implicit prepend: Prepend.Aux[HLObs, ObservableValue[O, P]::HNil, Appended]) = {
|
||||
hlist :+ f
|
||||
}
|
||||
|
||||
def uw[O, P, Appended <: HList, Unwrapped <: HList]
|
||||
(f: ObservableValue[O, P])
|
||||
(implicit prepend: Prepend.Aux[HLObs, ObservableValue[O, P]::HNil, Appended],
|
||||
uw: Mapper.Aux[ObservableUnwrapper.type, Appended, Unwrapped]): Unwrapped = {
|
||||
uw(hlist :+ f)
|
||||
}
|
||||
|
||||
def tp[O, P, Appended <: HList, Unwrapped <: HList, Tupled <: Product]
|
||||
(f: ObservableValue[O, P])
|
||||
(implicit prepend: Prepend.Aux[HLObs, ObservableValue[O, P]::HNil, Appended],
|
||||
uw: Mapper.Aux[ObservableUnwrapper.type, Appended, Unwrapped],
|
||||
tplr: Tupler.Aux[Unwrapped, Tupled]): Tupled = {
|
||||
uw(hlist :+ f).tupled
|
||||
}
|
||||
|
||||
def tl[O, P, Appended <: HList, Unwrapped <: HList, Tupled <: Product, ApList]
|
||||
(f: ObservableValue[O, P])
|
||||
(implicit prepend: Prepend.Aux[HLObs, ObservableValue[O, P]::HNil, Appended],
|
||||
uw: Mapper.Aux[ObservableUnwrapper.type, Appended, Unwrapped],
|
||||
tplr: Tupler.Aux[Unwrapped, Tupled],
|
||||
lst: ToList[Appended, Observable[_]]): Tupled = {
|
||||
val hl = hlist :+ f
|
||||
hl.toList
|
||||
uw(hl).tupled
|
||||
}
|
||||
|
||||
def |@|[O, P, Appended <: HList, Unwrapped <: HList, Tupled <: Product, ApList]
|
||||
(f: ObservableValue[O, P])
|
||||
(implicit prepend: Prepend.Aux[HLObs, ObservableValue[O, P]::HNil, Appended],
|
||||
@ -74,6 +43,21 @@ class ObservableTupler
|
||||
new ObservableTupler[Appended, Unwrapped, Tupled](newHL)
|
||||
}
|
||||
|
||||
def hlisted: ObservableValue[HLParams, HLParams] = {
|
||||
def calculate() = unwrapper(hlist)
|
||||
val original = calculate()
|
||||
val prop = ObjectProperty[HLParams](original)
|
||||
|
||||
for {
|
||||
component <- hlist.toList
|
||||
} {
|
||||
component onChange {
|
||||
prop.value = calculate()
|
||||
}
|
||||
}
|
||||
prop
|
||||
}
|
||||
|
||||
def tupled: ObservableValue[TParams, TParams] = {
|
||||
def calculate() = unwrapper(hlist).tupled
|
||||
|
||||
@ -90,7 +74,11 @@ class ObservableTupler
|
||||
prop
|
||||
}
|
||||
|
||||
def apply[C](f: TParams => C): Observable[C] = tupled map f
|
||||
def apply[Func, Result](f: Func)(implicit ffp: FnFromProduct.Aux[HLParams => Result, Func], ftp: FnToProduct.Aux[Func, HLParams => Result]): ObservableValue[Result, Result] = {
|
||||
hlisted map ftp(f)
|
||||
}
|
||||
|
||||
// def apply[C](f: TParams => C): Observable[C] = tupled map f
|
||||
}
|
||||
|
||||
object ObservableUnwrapper extends Poly1 {
|
||||
@ -98,7 +86,6 @@ object ObservableUnwrapper extends Poly1 {
|
||||
}
|
||||
|
||||
object ObservableTupler {
|
||||
|
||||
def apply[A, A1, B, B1](a: ObservableValue[A, A1], b: ObservableValue[B, B1]) = {
|
||||
new ObservableTupler(a::b::HNil)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user