https://kotlinlang.org logo
#functional
Title
# functional
p

Piotr Krzemiński

02/08/2023, 7:51 AM
I’m thinking about creating a tool that would promote a more functional approach in certain contexts, like forbid using
var
or
for
loops (mutability in general), with a way to opt out in certain cases. Think: a step towards more pure FP. I’m wondering if you’d be keen to use it and, if yes, what approach you’d suggest to implement it. I’m thinking about a detekt rule or a compiler plugin that would emit an error or a warning (configurable)
s

simon.vergauwen

02/08/2023, 7:55 AM
There is this project from https://github.com/neeffect/kure-potlin, but I don't have any experience with it. It already does some things you mentioned, but ultimately a compiler plugin would be best but I would wait until K2 is stable. With compiler plugins you can analyse code more deeply, and you can do more advanced things. Like Arrow-analysis, or provide refactor suggestions to auto-fix impure code to pure code, etc. With IDEA support like red-lines explaining why certain patterns should be avoided.
p

Piotr Krzemiński

02/08/2023, 8:05 AM
awesome, thanks!
2 Views