Whenever you read Arrow.kt tutorials, as they progress, they start touting as a benefit of FP that you can abstract away your types and write everything as things like fun <F> myFun(): Kind<F, A>
instead of fun myFun(): IO<A>
or fun myFun(): Option<A>
.
I understand what Kind<F, A>
means, but I don't understand why doing this is so beneficial. It seems to me what is being enabled is that your function could return an Option or an Either or an IO without having to change your types, but is that really such a big benefit?
I've never used FP in team projects or anything featuring hundreds of thousands of lines of code, so maybe refactoring this can be troublesome and Kind<F, A>
means you don't have to change functional signatures, just the code in the blocks, I'm not sure.
Can someone give me some concrete examples of this being useful in practice? An example where doing this has yielded some big benefit?
Like I can understand having an interface like Logger
and have a file logger, API-pinging logger, STDOUT logger, etc. implement and you can swap out, but is this the same thing? How?