Skip to content

Suspending version of the fold operator? #102

Open
@shubham08gupta

Description

@shubham08gupta

How about having a suspending version of the fold operator? Something like(please excuse the name):

suspend fun foldSuspend(fnL: suspend (L) -> Any, fnR: suspend (R) -> Any): Any =
        when (this) {
            is Left -> fnL(a)
            is Right -> fnR(b)
        }

Currently, it is:

 fun fold(fnL: (L) -> Any, fnR: (R) -> Any): Any =
        when (this) {
            is Left -> fnL(a)
            is Right -> fnR(b)
        }

Is it a good practice to keep 2 versions of the same function?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions