phldavies
10/03/2025, 11:17 AMcatch(block, transform, catch) override? Currently doing the equivalent of catch({ transform(block()) }, catch) would result in any exceptions from transform being handled by the catch function.Alejandro Serrano.Mena
10/03/2025, 11:28 AMfoldphldavies
10/03/2025, 11:29 AMfold is more as it introduces a redundant Raise<Error> and supporting mechanismphldavies
10/03/2025, 11:30 AM@RaiseDSL
public inline fun <A, B> catch(block: () -> A, transform: (value: A) -> B, catch: (throwable: Throwable) -> B): B {
contract {
callsInPlace(block, AT_MOST_ONCE)
callsInPlace(transform, AT_MOST_ONCE)
callsInPlace(catch, AT_MOST_ONCE)
}
val value = catch({ block() }, { return catch(it) })
return transform(value)
}
to discussAlejandro Serrano.Mena
10/03/2025, 11:30 AMphldavies
10/03/2025, 11:32 AMphldavies
10/03/2025, 11:32 AMfold but I had to provide Nothing for Error and realised it would create a redundant DefaultRaise etcsimon.vergauwen
10/06/2025, 7:51 AMI just want to be sure we're just not adding overloads just for the sake of itI'm open to reviewing the base functions, and seeing if we need to rename or introduce some new signatures for 2.3. I would also consider deprecating any confusing ones because since releasing them we've seen some confusion and gotten repeated questions about recover, catch & fold and when to use what.
phldavies
10/22/2025, 10:43 AMrecover and fold but not for catch - if there's to be a review for 2.3 I think it would be good to include it either in 2.2 or at least ensure the use-case is covered by any review of signatures.