Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

["Request"] Annotate Raise interface with @RaiseDSL #3415

Closed
pema4 opened this issue May 2, 2024 · 2 comments
Closed

["Request"] Annotate Raise interface with @RaiseDSL #3415

pema4 opened this issue May 2, 2024 · 2 comments

Comments

@pema4
Copy link

pema4 commented May 2, 2024

What version are you currently using? 1.2.4

What would you like to see?

According to DslMarker documentation, DSL marker is used to annotate interfaces/classes to limit visibility of their members in cases when there are multiple annotated receivers in scope.
But currently in Arrow @RaiseDSL annotation is not present on the Raise interface, only on its methods and extensions. Consequently, this code compiles and runs:

import arrow.core.raise.*

fun main() {
    either<Int, Int> {
        withError<Int, String, _>(String::length) {
            raise("23423") // correctly resolves to this@withError.raise
            raise(42) // error type does not match inner Raise, but the call still resolves to this@either.raise
        }
    }.also(::println)
    // prints Either.Left(5)
}
@kyay10
Copy link
Collaborator

kyay10 commented May 2, 2024

This is intentional behaviour. We want you to be able to set up multiple Raise instances, and be able to raise to any of them easily. This allows for easy error handling for multiple types

@serras
Copy link
Member

serras commented May 15, 2024

As mentioned by @kyay10, this is by design. Especially in accumulate environments, we want to still give the option to call the outer raise, to signal that accumulation has to stop.

@serras serras closed this as completed May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants