Hey! I'm working on a cross platform application u...
# arrow
j
Hey! I'm working on a cross platform application using MVI as the underlying architecture. I stumbled across an article about Arrow and using functional programming to implement simple dependency injection and I find it fascinating. I've only really done OOP so I find it somewhat confusing to see how I might incorporate Arrow; do you have any recommendations on where to start? ... Or should I just look into going back and getting a Phd in CS? 😄
j
@JimK If you're referring to so-called typeclassless DI (TDI), there's no direct relationship between it and Arrow, or between it and FP, other than that it originated in the Arrow community and the Arrow libraries use it. The DI technique leverages capabilities built into the Kotlin language itself. This should be good news, as grokking how to build well-designed fully FP applications is a WAAAAY bigger goal than switching to TDI. A couple days of experimentation, reading blog posts, and looking at examples was enough to get me rolling with TDI. I've made the switch from Dagger to TDI myself (like you, also in an MVI app) and I love it. This is in spite of my use and understanding of Arrow and FP being very much in the beginner phase.
j
I absolutely am talking about that! I want to dump kodein and take type classless on a date but don't know a good usecase in which to start.
I imagined some related readings may help me wrap my head around it
j
Typeclasses are for doing FP. I wrote all my DI without them. So not needed.
I'll share the resources I used...
j
Thanks so much!
In a nutshell, TDI is interface composition and extension functions. That's what I meant about only needing capabilities built into Kotlin itself, not Arrow or FP.
As for use-case / where-to-start, take a small portion of what you currently manage using Kodein, and see if you can have Kodein delegate to TDI code that you write to supply the dependency. That's a much more manageable starting point than trying to port your entire dependency graph all at once. Most of the app I'm working on still uses Dagger. But I had to build a new feature, so I used TDI just for that part. There's no problem mixing these two approaches in the same app.
❤️ 2
j
Wow, very very appreciated.
j
Sure thing! It pleases me to make it easier for another person to make the switch to TDI than it was for me.
Let me know how it goes.
j
This was exactly what I needed. Thanks again!
👍🏾 1