lucapiccinelli/konad

Curry() should take in infinite params

honzagula opened this issue · 4 comments

Hello,

first of all, this is the library that we were looking for. Thank you for it.

But most of our DTOs have more than 10 params and it's not possible to use curry method on them. it would be great if the curry method could take parameters dynamically.

Thanks

Hi thank you.
Unfortunately, it is impossible to have a curry method with infinite parameters in Kotlin (because of the generics). But the workaround is very easy. You can go in here https://github.com/lucapiccinelli/konad/blob/master/src/main/kotlin/io/konad/curry.kt add the number of parameters that you need and then open a PR. I will be happy to accept it.

I know that this method is not the best... but also other largely adopted libraries (like Arrow) use the same strategy.

I just published version number 1.0.7 that extends curry from generics arity of 11 to 23. Check it out and let me know if the issue can be considered closed

We wanted to use it on object with 50+ params and its not possible for kotlin to have method with that many generics. So we switched to pure kotlin instead of Konad.

Yes, we can consider this issue as closed.

Thank you.

I know that is not my business, but that large DTOs drive me to think that there is the possibility that a design issue is there. Maybe a lack of cohesion? Take it as just a wild guess.

Konad or not, let me introduce to you this article https://betterprogramming.pub/type-safe-domain-modeling-in-kotlin-425ddbc73732?source=friends_link&sk=2fedd10125b31cf7ca378878de4b3491

I hope it can be helpful. Cheers