Ulrich Schuster
12/27/2025, 12:53 PMwithError to wrap a function with RaiseAccumulate<MyErrorA> receiver, when the outer error context is Raise<MyErrorB> ?
When I try
context(_: Raise<MyErrorB>)
fun validateOuter(x: X): X = withError({ errors -> MyErrorB(errors) } ) { validateInner(x) }
where
context(_: RaiseAccumulate<MyErrorA>)
fun validateInner(x: X)
the type checker complains about no context argument found for validateInner() How can I tell withError to open a RaiseAccumulate context?Youssef Shoaib [MOD]
12/27/2025, 1:02 PMiorAccumulate(block).mapLeft(transform).bind()Ulrich Schuster
12/27/2025, 1:05 PMUlrich Schuster
12/27/2025, 1:05 PMYoussef Shoaib [MOD]
12/27/2025, 1:06 PMwithError might cause resolution issues (especially with context paramters)Ulrich Schuster
12/27/2025, 1:13 PMwithErrorNel?Ulrich Schuster
12/27/2025, 1:14 PMRaiseAccumulate<Error> and Raise<Nel<Error>> ? I find myself confused sometimes when trying to get the types line upYoussef Shoaib [MOD]
12/27/2025, 1:18 PMRaiseAccumulate was just a hidden Raise<Nel<Error>>, which can be accessed through withNel, and it exposes a Raise<Error> to make your life easier.
With the new experimental DSL, RaiseAccumulate now has a whole Accumulate API, which allows you to accumulate errors as you go about your computation. That's what allows for binding Ior, since if you have a Both, the error should go somewhere.
To go from Raise<Nel<Error>> to RaiseAccumulate<Error>, simply use the accumulate { } block.