phldavies
07/03/2024, 4:26 PMarrow.core.raise.fold
declare callsInPlace(block, EXACTLY_ONCE)
? - edit: short answer is noCLOVIS
07/03/2024, 6:58 PMfold
overload you mean? There are a few... https://apidocs.arrow-kt.io/arrow-core/arrow.core.raise/fold.htmlCLOVIS
07/03/2024, 6:59 PMblock
, recover
and transform
, then I think so, yes 🤔phldavies
07/03/2024, 7:04 PMfold
overloads that take a block: Raise<Error>.() -> A
seem to not specify callsInPlace
for block
- however I see in 2.x some of them now do (but declare it as AT_MOST_ONCE despite it seemingly always being calledphldavies
07/03/2024, 7:36 PMAT_MOST_ONCE
as it may not complete, despite the surrounding function call completingphldavies
07/03/2024, 7:38 PMfun main() {
val s: String
fold<Unit, _, _>({
ensure(false) {}
s = "hello"
}, { throw it }, {}, {})
println(s.length)
}
this would compile with EXACTLY_ONCE
but (correctly) fail to compile with AT_MOST_ONCE
CLOVIS
07/03/2024, 9:39 PMEXACTLY_ONCE
can only be used if it runs to completion? But how can you know that in the general case, exceptions could be thrown anywhere?phldavies
07/03/2024, 9:49 PMEXACTLY_ONCE
means "if the outer function completes, the inner function was invoked and completed exactly once"phldavies
07/03/2024, 9:56 PMWrong invocation kind 'EXACTLY_ONCE' for 'block: () -> Unit' specified, the actual invocation kind is 'AT_MOST_ONCE'.