Repository navigation
Replies: 3 comments 1 reply
|
Hey @i-walker, Great suggestion, this is something that was considered when working on these new signatures but there are some trade-offs.
In the first signature, the one you proposed, it's no longer possible to pass
Given that So the same syntax can easily be achieved by splitting off in a seperate context aware function. With multiple receivers this could potentially improve even further since a user might be able to do: context(EitherEffect<Error, *>)
suspend fun List<Int>.saveAllKeywordsWithTraverse(): List<Unit> =
map {
val keys = getUserFromId(id).bind().savedKeywords
saveKeywords(keys).bind()
} |
|
This is solved by |
|
|
Uh oh!
There was an error while loading. Please reload this page.
The following approach can be extended to any other algebra, datatype or
parTraverse.In 0.13.2 we define traverseEither:
consider this example:
but
either.invoke+mapistraverseEither- with the difference that we want to have more than just one computational binding.This is an alternative, which allows users to use
EitherEffectas they traverseand our example above is achieved with:
One may note that the definition of
traverseEitheris using theshiftandresetfunctionality only for the end result. Making it a special case of what delimited continuations provides.The question to the community is wether we should adopt this in
Validated,Eitherand other places wherebindis used e.g.:nullable.Please leave any Feedback :)
All reactions