registry

A small dependency-injection / wiring library for Scala 3.

A Registry is a list of functions and values. The Registry main function, make[T], can be called to make a value of type T by invoking the first function that returns a T. The function parameters are retrieved by recursively calling make on the Registry. That’s it!

import registry.*

case class Host(value: String)
case class Port(value: Int)
case class DbConfig(host: Host, port: Port)
case class App(db: DbConfig)

val r =
  fun[App] +:
    fun[DbConfig] +:
    value(Host("localhost")) +:
    value(Port(5432))
val app: App = r.make[App]
// app: App = App(DbConfig(host = Host("localhost"), port = Port(5432)))

Learn more:


This site uses Just the Docs, a documentation theme for Jekyll.