raulraja
11/04/2018, 6:17 PMandThen
, compose
, partiallyN
etc.
If your architecture already includes some more complex data types or transformers you can also use Reader
and ReaderT
.
On the other hand in the most common use case where people use a tagless final style which is the most popular and efficient in typed FP, dependencies are injected in constructors in a similar fashion as you would do in Dagger2 or other DI frameworks.
Here is an example of a tagless final polymorphic program that works over many data types (IO in the example) and that injects dependencies manually via constructor:
https://gist.github.com/raulraja/e5f09c0cbd1392cf4eee5415150ebf76
If you keep state and behavior separated from Data in components your dependencies are just plain objects, package level static functions or classes that provide extensions or static behavior so using them directly or using constructor based injection it's simple and trivial.