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"] Investigate providing type hints using DeprecationLevel.ERROR #2838

Open
nomisRev opened this issue Oct 7, 2022 · 2 comments
Open
Assignees

Comments

@nomisRev
Copy link
Member

nomisRev commented Oct 7, 2022

What version are you currently using?

1.x.x

What would you like to see?

Sometimes it's not clear why Either<Throwable, Int> cannot be bind inside either<String, A> { },
and similarly with other data types that don't match the logical failure channel type.

Based on some discussions on Twitter, and Slack we discovered that you can leverage DeprecationLevel.ERROR to provide hints to the user, to clarify why the signature results in a ERROR.

We can on a per type/signature basis provide better error messages to the user. I.e.

  • "Option.bind() cannot be called with different error type, use mapLeft to transform None into the same error type"
  • "Either.bind() can only be called with the Left type, or subtype. Use mapLeft to transform the error type.
  • ...

Screenshot 2022-10-06 at 17 41 17

https://twitter.com/vergauwen_simon/status/1578047840227557379?s=20&t=REup7C6kEet76dtI66gUIQ
https://kotlinlang.slack.com/archives/C5UPMM0A0/p1665068590923969

@kyay10
Copy link
Collaborator

kyay10 commented Feb 6, 2024

I'll take a stab at this in arrow-context, since I think contexts could make implementing this pattern a lot easier. My only fear is that collisions could happen where the inner context binds stronger to such an erroneous declaration than an outer context, but I'll test out and see if that's the case.

@kyay10 kyay10 self-assigned this Feb 6, 2024
@nomisRev
Copy link
Member Author

nomisRev commented Feb 7, 2024

My only fear is that collisions could happen where the inner context binds stronger to such an erroneous declaration than an outer context, but I'll test out and see if that's the case.

Yes, that is most likely going to occur but in those case need to explicitly call implicit<OutScope>().function(), right? Perhaps clarifying in the message is enough? Ideally, this would be done with fully flexed IDEA support but looks like that won't ever happen from Kotlin plugins.

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

2 participants