https://kotlinlang.org logo
#arrow
Title
f

Farid Benhaimoud

09/09/2023, 12:09 PM
Hello all, Will we have context receivers for multiplatform in the near future? Or is this more a question for the jetbrains team?
d

Davio

09/09/2023, 2:46 PM
I think they were targeted for Kotlin 2, but may not make it in 2.0 as I understand there might still be some work to be done. I'm anxiously awaiting it, since context receivers not being available is one of the reasons we removed Arrow from our project
f

Farid Benhaimoud

09/09/2023, 2:51 PM
Ah thnx @Davio for curiosity’s sake, Why don’t use it without context receivers? I am going to use it first in my ktor backend, after that I hope in my KMM/KMP proect
c

CLOVIS

09/09/2023, 5:33 PM
No official announcements yet. We suspect they will be experimental in multiplatform in 2.1 or 2.2, no idea when they will become stable.
d

Davio

09/10/2023, 9:20 AM
@Farid Benhaimoud it's a personal preference, but we only used it for error handling and found that the puristic functional approach of Arrow with functions returning Eithers where you never know what right or left means was not better for our code base. So we went with a less enforcing, but more readable approach of just throwing exceptions and making sure we handle them when we cross a boundary such as from/to our domain code. It's not perfect, but it works. And if we want a more functional approach we can just use the inbuilt Result type.
c

CLOVIS

09/10/2023, 10:59 AM
where you never know what right or left means
Right is always successful, left is always an error.
we can just use the inbuilt Result type
Seriously, do not use runCatching. You can search through this slack to know the details, it has many, many issues (including creating zombie coroutines)
d

Davio

09/10/2023, 11:57 AM
We do not use runCatching because it catches everything, also exceptions that should not be catched such as Errors and CancellationExceptions, but some basic try catch stuff and since it's only in a few places it's not that bad. It also makes tests a lot easier to write
👍 1
c

CLOVIS

09/10/2023, 11:58 AM
No problem then, I just see way too many people having issues with bad usage of Result in this Slack
2 Views