Last active
November 22, 2019 16:04
-
-
Save deeperunderstanding/919e024808b692a09ea54746e6f9c59c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias ResultSet<T> = Pair<List<Success<T>>, List<Failure<T>>> | |
fun <T> List<Try<T>>.asResultSet(): ResultSet<T> = this.partition { it is Success } as ResultSet<T> | |
fun <T, R> ResultSet<T>.map(transform: (T) -> R): ResultSet<R> = | |
this.first.map { it.map(transform) }.asResultSet().let { result -> | |
Pair(result.first, this.second as List<Failure<R>> + result.second) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment