Add a new type to the environment inside a for-comprehension.
Add a new type to the environment inside a for-comprehension. This variant is for an environment that's constructed directly.
This method takes the "current" environment type, and enriches it with the given value. The remainder of the for-comprehension can then access that environment. For example, instead of this:
for { someValue <- computeThing myEnv1 <- Env.enrich[Env1 with Env2](CreateMyEnv(someValue)) thing1 <- doThing1.provide(myEnv1) thing2 <- doThing2.provide(myEnv1) // etc } yield thing2
You can do this:
for { someValue <- computeThing _ <- Env.add[Env1 with Env2](CreateMyEnv(someValue)) thing1 <- doThing1 thing2 <- doThing2 } yield thing2
The MyEnv environment is automatically provided to the continuation after Env.add, so it doesn't have to be named and explicitly provided everywhere.
Add a new type to the environment inside a for-comprehension.
Add a new type to the environment inside a for-comprehension. This variant is for an environment that's constructed effectfully.
This method takes the "current" environment type, and enriches it with the given value. The remainder of the for-comprehension can then access that environment. For example, instead of this:
for { someValue <- computeThing myEnv1 <- Env.enrichM[Env1 with Env2](CreateMyEnv(someValue)) thing1 <- doThing1.provide(myEnv1) thing2 <- doThing2.provide(myEnv1) // etc } yield thing2
You can do this:
for { someValue <- computeThing _ <- Env.addM[Env1 with Env2](CreateMyEnv(someValue)) thing1 <- doThing1 thing2 <- doThing2 } yield thing2
The MyEnv environment is automatically provided to the continuation after Env.addM, so it doesn't have to be named and explicitly provided everywhere.
Some utilities for enrichment of environment