Created
November 1, 2018 16:13
-
-
Save kell18/05261e56504da16d5db8384a4ad65733 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class FunctionNPhase[Event, States <: HList, Phases <: HList]( | |
function: Seq[Double] => Double, | |
functionName: String, | |
innerPhases: Phases | |
)(implicit ev: Mapped.Aux[States, ({ type T[State] = NumericPhaseParser[Event, State] })#T, Phases]) | |
extends Pattern[Event, States, Double] { | |
private val initialStateGetter = new (({ type U[State] = NumericPhaseParser[Event, State] })#U ~> Id) { | |
override def apply[T](f: NumericPhaseParser[Event, T]): Id[T] = f.initialState | |
} | |
override def initialState: States = innerPhases.map(initialStateGetter) | |
override def apply(event: Event, state: States): (PatternResult[Double], States) = ??? | |
{ | |
val allPhasesTogether = | |
innerPhases.foldLeft((f: NumericPhaseParser[Event, _], g: NumericPhaseParser[Event, _]) => f togetherWith g) | |
val (results, newState) = allPhasesTogether(event, state) | |
// FIXME@trolley813: it's pseudocode, won't work | |
results.map { case x => function(x.toSeq) } -> newState | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment