A convenience class to construct stackable modules. This variant
operates over stacks and the entire parameter map. The ModuleN variants
may be more convenient for most definitions as they operate over T types
and the parameter extraction is derived from type parameters.
ModuleParams is similar, except it requires parameters to be declared.
def myNode = new Module[Int=>Int]("myelem") {
val role = "Multiplier"val description = "Multiplies values by a multiplier"val parameters = Seq(implicitly[Stack.Param[Multiplied]])
def make(params: Params, next: Stack[Int=>Int]): Stack[Int=>Int] = {
val Multiplier(m) = params[Multiplier]
if (m == 1) next // It's a no-op, skip it.else Stack.Leaf("multiply", i => next.make(params)(i)*m)
}
}
A convenience class to construct stackable modules. This variant operates over stacks and the entire parameter map. The
ModuleN
variants may be more convenient for most definitions as they operate overT
types and the parameter extraction is derived from type parameters.ModuleParams
is similar, except it requiresparameters
to be declared.