extension function to bind Akkurate's ValidationResult to Arrow's Raise blocks:
Copy code
either {
someResult.bind()
}
However, this requires to use context receivers, which are currently JVM-only.
What would you recommend to support multiplatform?
Having two extension functions? One with context receivers for JVM, and another one with a parameter for other targets?
Copy code
@context(Raise<NonEmptySet<ConstraintViolation>>)
fun <T> ValidationResult<T>.bind()
fun <T> Raise<NonEmptySet<ConstraintViolation>>.bind(validationResult: ValidationResult<T>)
a
Alejandro Serrano.Mena
12/07/2023, 12:37 PM
I would argue against that, because context receivers are still in flux... may for the time being you can do the one without contexts, I think it would be very useful even if the syntax is not 100% what one would expect
j
Johann Pardanaud
12/07/2023, 12:46 PM
I thought Arrow was using them, but maybe they're only shown in the documentation but not used inside the codebase?
a
Alejandro Serrano.Mena
12/07/2023, 12:47 PM
they are not used because it would make the library not apt for consumption... this is why we resort to "tricks" such as the
RaiseAccumulate
extending
Raise
Alejandro Serrano.Mena
12/07/2023, 12:48 PM
since they are very useful even in their current form, we talk about them in the Design section of the docs