-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
["Request"] Ease NonEmptyCollection methods usage calling suspend #3116
Comments
The problem here is that
What do you think? Summoning also @nomisRev @raulraja @franciscodr to the conversation. |
Hmm, we can not solve this for the @Suppress("OVERRIDE_BY_INLINE")
public override inline fun <B> map(transform: (A) -> B): NonEmptyList<B> =
NonEmptyList(transform(head), tail.map(transform)) This works for example, whilst public suspend fun mySuspendFunction(value: Int): Int = TODO()
public suspend fun mapIndexedOnNonEmptyList(): NonEmptyList<Int> =
nonEmptyListOf(1, 3, 7).map { value: Int -> mySuspendFunction(value) } |
What version are you currently using?
1.2.0
What would you like to see?
Currently, the following
mapIndexedOnNonEmptyList
method get aSuspension functions can be called only within coroutine body
compilation error, but notmapIndexedOnStandardCollection
:I would like to be able to use
NonEmptyCollection
methods in a suspend method definition the same way you can on standard collections.(note that the standard collection behavior is due to
inline
method definition ofIterable<T>.mapIndexed
)Why?
I think that it would ease
NonEmptyCollection
usage (to avoid custom extensions or to avoid switching back on standard collections).The text was updated successfully, but these errors were encountered: