kyleg
01/22/2020, 5:52 PMTry is deprecated, is the preferred replacement for (non-suspending) Try { … } :
1. an explicit try { Either.right(…) } catch(e) { Either.left(…) } or
2. runBlocking { Either.catch { … } } (which is a suspend fun)pakoito
01/22/2020, 5:56 PMEither.catch { } for suspend onespakoito
01/22/2020, 5:57 PMpakoito
01/22/2020, 5:57 PMpakoito
01/22/2020, 5:58 PMkyleg
01/22/2020, 5:59 PMDataTypeExamples.kt with a whole block of Try examples. The Either examples are fewer, so I’m trying to replace those Try with more Either .
The docs explicitly contrast the “old school” try/catch with newer Try {…}, so it seemed like try { Either.right } catch { Either.left } was a little inelegant considering it’d be contrasted with “old school” try/catch block 😛simon.vergauwen
01/22/2020, 6:03 PMtry/catch/finally works fine in pure code is because it can not fail on you there. In code with async jumps and cancelation it can work incorrectly.simon.vergauwen
01/22/2020, 6:04 PMTry since try/catch with Either works just as well with less abstractions.kyleg
01/22/2020, 6:05 PMTry as just syntactic sugar for try/catch and hadn’t questioned whether functional purity played a role.
I suppose this is one reason IO and suspend fun are connected in Arrow. The issue around async jumps and error handling.Attila Domokos
01/22/2020, 6:11 PMIO ftw!