Automatic Dependency Injection in Scala - Just the Type System!

Описание к видео Automatic Dependency Injection in Scala - Just the Type System!

GitHub: https://github.com/scala/scala3/blob/...
Learn ZIO: https://rockthejvm.com/p/zio

In this video we will demonstrate a technique for automatic dependency injection in pure Scala with no other libraries or frameworks. Here, instances are passed automatically just by the structure of the types in question, without relying on macros, annotations, reflection or any runtime behavior. The technique is based on an example from Martin Odersky after an informal discussion (shared with his permission).

We'll cover
- a scenario where dependency injection is useful
- how explicit dependency injection is done
- how the ZIO library manages dependency injection with ZLayers
- how we can use givens, match types and a minimum of type-level programming to make the compiler automatically infer which instances need to be injected in which place

Follow Rock the JVM on:
LinkedIn:   / rockthejvm  
X: https://x.com/rockthejvm
Blog: https://blog.rockthejvm.com

-------------------------------------------------------------------------
Home: https://rockthejvm.com
-------------------------------------------------------------------------

Комментарии

Информация по комментариям в разработке