simon.vergauwen
05/31/2022, 2:32 PMGiulio Caccin
06/01/2022, 1:48 PMYoussef Shoaib [MOD]
06/02/2022, 4:09 PMwith
was mentioned! I felt star-struck seeing a workaround that I found actively being used and resulting in (slightly) neater Kotlin code :) thankfully that bug is getting fixed in 1.7.20 though so hopefully multi-context with
will be part of the stdlib soon!Pavel
06/02/2022, 6:42 PMStylianos Gakis
06/03/2022, 9:57 PMEffectScope<DomainError>
but that's something I'd love to hear more community discussions about. But that's a mild detail if anything.Youssef Shoaib [MOD]
06/04/2022, 11:21 AMcontext(EffectScope<DomainError>)
declare that they need the caller to be able to handle errors of type DomainError
. It's just asking for an error handler, which is quite a common pattern already.Stylianos Gakis
06/04/2022, 2:46 PMsimon.vergauwen
06/05/2022, 2:27 PMEffectScope
vs Either
, perhaps I should've been more explicit in the webinar. I am not suggesting that using context(EffectScope<E>)
is better than returning Either<E, A>
. Like a lot of things in software, it's more about the properties of the pattern. In this case, the expected error is typed E
rather than an implicit Throwable
. Either style holds that property so I would say it's purely a matter of preference. I gave the same answer here, https://stackoverflow.com/questions/72277426/which-should-we-choose-between-effect-an[…]either-as-a-return-type-of-our-busines/72277572?noredirect=1.
There are a couple of places where one might prefer using context(EffectScope<E>)
over Either<E, A>
and that would be to unluck tailrec
for example in the attached code.
You can also find it here in the example project, https://github.com/nomisRev/ktor-arrow-example/pull/35/files#diff-776f1016c7b6c2c2bd6b1ba00b5a0a0ec321e140dc519e0941014bb6f39e599esimon.vergauwen
06/05/2022, 2:29 PMsimon.vergauwen
06/05/2022, 2:38 PMtailrec
, but the second one is not.Stylianos Gakis
06/06/2022, 11:59 AMI am sure we’re not finished discovering context receivers, and that is probably both in use-cases and downsides. They’re very powerful.Absolutely! Super eager to see what else people come up with and what ends up being not that good after-all 😅