Your intuition that you need to collect both the value of the dependent type ( env.Population
) and the value that the type depends on ( env
) as one object exactly matches.
Given the definitions you already posted, probably the easiest approach would be something like this,
Now, if we define a specific type of environment,
class ConcreteEnvironment extends Environment { class Population extends PopulationBase def evolveUs(population: Population): Population = population }
we can use it directly, as before,
val e1 = new ConcreteEnvironment val p1 = new e1.Population val p2 = e1.evolveUs(p1) val p3 = e1.evolveUs(p2)
and we can also pack the environment and population for distribution,
def distrib(ep : EvolvePopulation) { import ep._ val p4 = env.evolveUs(prevPopulation) val p5 = env.evolveUs(p4) val p6 = env.evolveUs(p5) } val ep1 = EvolvePopulation(e1)(p3) distrib(ep1)
source share