There are 2 repos in arrow-kt "arrow-inject" and "...
# arrow
j
There are 2 repos in arrow-kt "arrow-inject" and "arrow-proofs" From the commits I guess that arrow-proofs is the way to go in the future, right ? ...so that instead of this
Copy code
fun createUser(bookInput: BookInput): ResponseEntity<ParsedBookResponse> =
   with(bookInput) {
      withParsedBook().fold(....)
...we can have this ?
Copy code
fun createUser(bookInput: BookInput): ResponseEntity<ParsedBookResponse> =
      withParsedBook().fold(....)
...by annotation + compiler plugin or Kotlin context receiver ? Currently I have this function:
Copy code
context(BookInput)
fun withParsedBook(): Validated<NonEmptyList<String>, ParsedBook> {....}
from this example I guess we still need that context<MyDependency> instead of with(MyDependency) ?
r
Hi @Jörg Winter, Arrow proofs is the current ongoing effort over a compiler plugin based on the new compiler FIR and k2. FIR is still not stable but when it comes out it will work on the IDE too. Proofs will focus on context receiver resolution. For example https://github.com/arrow-kt/arrow-proofs/tree/main/arrow-inject-compiler-plugin/src/testData/box/context-receivers Instead of
with
and a lambda you will be able to bring
@Provider
into the scope using
context<A, B, C, ...>
. for example:
j
In that example, if f() had the dependencies as parameters, would they be injected into another receiving function that is called inside f() ?
r
They are exclusively injected when you summon their types with
context<A, B, ...>
. If you had declared instead those as context parameters to the function then when you call the function you have to summon them with
context
. It's possible to make it all implicit and just allow the call to resolve them magically based on what is missing, but we have not made a decision yet on whether that is a good idea or
context<A, B..
should be explicit.