435225 (3) [Avatar] Offline
#1
I have a question about implementing Dependency Injection with Kleisli.

For instance take a look at the chapter five example code: https://github.com/debasishg/frdomain/tree/master/src/main/scala/frdomain/ch5

Here we have AccountService that is configurable with Kleisli. AccountService depends on some AccountRepository. But AccountRepository implementation does not need any configuration there and is not configurable because its methods return \/ instead of Kleislis. But what if we need to provide some configuration to the AccountRepository as well? How should we refactor the code to handle it?
Debasish Ghosh (113) [Avatar] Offline
#2
Sorry for the late reply. I need to find some time to code an example for this. Unfortunately I haven't yet been able to find that time. But it's definitely possible. You need to compose the construction of repositories and services within one monadic expression. Then finally when you run the expression you supply the values from the environment. If this helps, it's great, otherwise I will work up an example for you ..

Pls let me know ..

Thanks.
435225 (3) [Avatar] Offline
#3
Thanks for the reply and for the book!

It would be awesome to see some example. Here I've prepared a gist, which I believe should clarify my question a little bit:
https://gist.github.com/akozhemiakin/55a02f327361243af56d92f2aac6177e
Debasish Ghosh (113) [Avatar] Offline
#4
I will take a look next week during the holidays when I have some spare time. Meanwhile I am too much stressed out with work related activities. Thanks for the gist - I will explore how we can make it more functional. Meanwhile you can take a look at https://libraries.io/github/zalando/grafter - it may have something that solves your issue.

Thanks.
435225 (3) [Avatar] Offline
#5
Awesome! Thanks.
I'll definitely look at Grafter. I do not expect anything but brilliant from the creator of Eff ))
312748 (5) [Avatar] Offline
#6
Any chance of seeing examples of cases where a method needs multiple repositories as dependencies?