Basically, a formalization of Dagger/Guice into a language.
Basically, a formalization of Dagger/Guice into a language.
An approach to do it statically is with implicit parameters. Scala has them, for example.
https://itnext.io/hmock-first-rate-mocks-in-haskell-e59d7c3b...
What other ways do you have in mind?
I am not aware of any Haskell functionality or compiler flag that enables implicit parameter passing, like Java, Kotlin, and Rust allow.
There are some examples, e.g. the Bevy ECS doing more or less dependency injection for you (and ensuring against things like aliased mutable references), which is pretty neat.
Reminds me of implicit parameters in Scala - https://docs.scala-lang.org/tour/implicit-parameters.html
Edit: I think I like it. It doesn't solve dependency injection like e.g. Guice but the examples given, e.g. providing implementations for traits defined in external crates that take arbitrary state, is compelling.