Hi, I’m starting with Kotlin and was wondering what was the “go to” for dependency injection… I saw that Kotlin has classic “DI containers” but was wondering if Arrow provided a more FP solution. (Environmental effects à la ZIO, or a more classic approach à la ReaderT)
r
raulraja
06/05/2021, 3:44 PM
Hi @Roger Cyr, Arrow used to have Reader but we found it mostly useless over time given Kotlin natively supports extension receivers and suspension.
For example
suspend Foo.doStuff(): Unit
is equivalent to
ReaderT<IO, Foo, Unit>
and can also be passed as value and has type of
suspend Foo.() -> Unit
. this also applies to other names like “Environmental Effects” which I think just means here the suspended effect has access to the scope of its receiver and this receiver can be passed in any call site as argument.
raulraja
06/05/2021, 3:47 PM
Additionally those abstractions rewrap functions which means double boxing for the most part, this is also a reason why we tossed them in Arrow as general abstractions