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

Add Sync helpers for scala.Predef assertions #3044

Closed
wants to merge 2 commits into from
Closed

Add Sync helpers for scala.Predef assertions #3044

wants to merge 2 commits into from

Conversation

DavidGregory084
Copy link
Member

I'm opening this for discussion after the idea came up while chatting with @armanbilge on typelevel/bobcats#106.

I'm not 100% sure whether this is a useful addition - I have some sympathy for the idea that assert and require express critical preconditions and that it's okay if the runtime explodes if those preconditions are not satisfied.

I chose Sync because I think it's the first place in the hierarchy that knows that the error channel is Throwable.

@armanbilge
Copy link
Member

I chose Sync because I think it's the first place in the hierarchy that knows that the error channel is Throwable.

Thanks for the PR! I guess I wasn't very clear in typelevel/bobcats#106 (comment) but actually I think these belong in Cats alongside ApplicativeThrow#catchNonFatal and friends (note that ApplicativeThrow is a type alias for ApplicativeError[*, Throwable]).

Sync is a very strong constraint and may not always be where this functionality is needed.

@DavidGregory084
Copy link
Member Author

Hmm OK, so we would add these as extension methods on ApplicativeThrow?

@armanbilge
Copy link
Member

So Cats add the methods to ApplicativeError but requires evidence that Throwable <:< E
https://github.com/typelevel/cats/blob/9839b7498e81b1405d3e41c88d24ce73e316e69d/core/src/main/scala/cats/ApplicativeError.scala#L247

@rossabaker
Copy link
Member

Because I had to look it up, AssertionError is NonFatal. I agree that ApplicativeError would work well.

@DavidGregory084
Copy link
Member Author

Superseded by typelevel/cats#4249

@DavidGregory084 DavidGregory084 deleted the predef-assertions branch June 21, 2022 16:41
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

Successfully merging this pull request may close these issues.

3 participants