Replies: 2 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()
} |
Beta Was this translation helpful? Give feedback.
-
This is solved by |
Beta Was this translation helpful? Give feedback.
-
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
+map
istraverseEither
- with the difference that we want to have more than just one computational binding.This is an alternative, which allows users to use
EitherEffect
as they traverseand our example above is achieved with:
One may note that the definition of
traverseEither
is using theshift
andreset
functionality 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
,Either
and other places wherebind
is used e.g.:nullable
.Please leave any Feedback :)
Beta Was this translation helpful? Give feedback.
All reactions