Nick Kleban
01/08/2024, 8:40 AMŁukasz Gendek
01/08/2024, 9:05 AMCLOVIS
01/08/2024, 9:06 AMStream.map
in Java. With the growing popularity of lambda-based programming, this made checked exceptions completely unusable.
Also, exceptions are dealt with very differently from "normal" values: you have to use try-catch, you have to use @Throws, etc. With Arrow, it's all just normal Kotlin code, like you could do for any other value.CLOVIS
01/08/2024, 9:08 AMinline
functions, the reified
keyword, the suspend
keyword, the @Composable
annotation… Raise
is the same pattern adapted to error management.CLOVIS
01/08/2024, 9:11 AMRaise
is more performant than checked exceptions because it doesn't generate the stacktrace, which is an expensive operation (but I could be wrong on that, I'm not an expert)streetsofboston
01/08/2024, 12:54 PMCLOVIS
01/08/2024, 1:25 PMRaise
?Łukasz Gendek
01/08/2024, 1:31 PMYoussef Shoaib [MOD]
01/08/2024, 2:04 PMRaise
is absolutely referentially transparent. The implementation obviously uses non-pure things, but so does map
for instance lol. Taking in a Raise
instance is you declaring that you need some error-handler in scope that can handle that error. Raise
doesn't allow you to catch something that was intended for a different Raise
instance, and for good reason.Nick Kleban
01/08/2024, 4:05 PMRiccardo Cardin
01/08/2024, 8:22 PMEither
or a Result
. Unchecked exceptions were made for bugs and unexpected errors.
The exception framework needed to be understood by developers from the very beginning. So. the language evolved, preferring unchecked exceptions, which compose well with lambdas but lack compiler support.CLOVIS
01/09/2024, 9:16 AMSo. the language evolved, preferring unchecked exceptions, which compose well with lambdas but lack compiler support.This is mostly because they are part of the signature, not the type. This is why they couldn't be supported by lambdas, etc. In Kotlin, context receivers are part of the type, so there's no need for new concepts everywhere to make them work.
Riccardo Cardin
01/09/2024, 9:25 AM