`Raise` with context parameters
The time has finally come to provide Raise with context parameters! Note that if we publish this library, users still need to use -Xskip-prerelease-check in their build file.
This PR is the start of the conversation of which functions we should expose using context-parameters-style. In this case I've decided to go with the following idea: minimize the amount of additional functions, while allowing people to freely define their functions as:
context(_: Raise<Something>) fun foo() = ...
More concretely, this implies:
- No "runner functions" (
either,option, etcetera) with contextual functions. The current functions work still OK with contextual parameters, since the receiver is part of context parameter resolution, - (Finally!) expose
bindAllandmapOrAccumulatewith the iterable/sequence/map being a receiver.
Thanks for pinging me on this! I'll have a look really soon! I had some ideas in a repo called arrow-context, but that's out-of-date now since it was using context receivers
Kover Report
| Total Project Coverage | 47.32% |
|---|
Okay... I need to refactor my project 😂
Note that if we publish this library, users still need to use
-Xskip-prerelease-checkin their build file.
It seems that context parameters will not force pre-release binaries. https://github.com/JetBrains/kotlin/blob/6f1bfe9fa11be40ff96ca01b8a55dfc5dde67f47/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt#L485
Since context parameters will not poison the binary, maybe we should just include these functions in arrow-core? WDYT @nomisRev?
Yes, sounds good to me!
Could it be that in your contextual bridge function you did not put all of the contract definition as done by the Raise member functions? I.e.: ensureNotNull misses the invocation contract for the otherwise lambda.
Closed in favor of #3646