Skip to content

Instantly share code, notes, and snippets.

@cvogt
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cvogt/81eeaf0a48c7810442ac to your computer and use it in GitHub Desktop.
Save cvogt/81eeaf0a48c7810442ac to your computer and use it in GitHub Desktop.
TMap with mutual dependencies
// ideal world, where every library has a tmap enabled monadic interface:
object Dep1Lib{
def doSomeThing = for{
dep1context <- Implicit[Dep1Context]
dep3context <- Implicit[Dep3Context]
} yield /* ... do something ... */
}
object Dep3Lib{
def doSomeThingElse = for{
dep3context <- Implicit[Dep3Context]
dep1context <- Implicit[Dep1Context]
} yield /* ... do something ... */
}
val dep1 = new Dep1Context
val dep3 = new Dep3Context
val deps = TMap(dep1) ++ TMap(dep3)
object Dep1.doSomeThing(deps)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment