Jörg Winter
08/23/2022, 11:19 AMfun createUser(bookInput: BookInput): ResponseEntity<ParsedBookResponse> =
with(bookInput) {
withParsedBook().fold(....)
...we can have this ?
fun createUser(bookInput: BookInput): ResponseEntity<ParsedBookResponse> =
withParsedBook().fold(....)
...by annotation + compiler plugin or Kotlin context receiver ?
Currently I have this function:
context(BookInput)
fun withParsedBook(): Validated<NonEmptyList<String>, ParsedBook> {....}
from this example I guess we still need that context<MyDependency> instead of with(MyDependency) ?raulraja
08/23/2022, 12:56 PMwith
and a lambda you will be able to bring @Provider
into the scope using context<A, B, C, ...>
. for example:Jörg Winter
08/23/2022, 1:01 PMraulraja
08/23/2022, 1:13 PMcontext<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.