Skip to content

2.2.0

Choose a tag to compare

@michaelbull michaelbull released this 11 Mar 22:13
· 37 commits to master since this release

Fallible Operations (try*)

Fallible collection operations now use a try prefix, inspired by Gleam's naming convention and mirroring stdlib's collection API more closely. Several new operations have also been added.

  • Rename mapResult* functions to tryMap*, mapAll to tryMap, fold/foldRight to tryFold/tryFoldRight (d052cf5)
    • The previous names are deprecated with @Deprecated + ReplaceWith for easy migration
  • Add tryFind, tryFindLast, tryForEach, tryForEachIndexed, tryReduce, tryReduceIndexed for Iterable (d2011f0)
  • Add tryFilter, tryAssociate, tryFlatMap, tryGroupBy, tryPartition + variants for Iterable (f32985e)

Flow Extensions

The kotlin-result-coroutines module now includes extensions for the kotlinx-coroutines Flow type, bringing the same Result-aware operations available on Iterable to asynchronous streams. This was born out of the discussion in #78.

  • Add Flow extensions for kotlin-coroutines (15d44a0)
    • Factory: Result<Flow<V>, E>.toFlow()
    • Flow: filterOk, filterErr, onEachOk, onEachErr, allOk, allErr, anyOk, anyErr, countOk, countErr, partition, combine, combineErr
    • Try: tryFilter, tryFilterNot, tryMap, tryMapNotNull, tryFlatMap, tryForEach, tryReduce, tryFold, tryFind, tryFindLast, tryAssociate, tryAssociateBy, tryAssociateWith, tryGroupBy, tryPartition

Other

  • Rename onSuccess/onFailure to onOk/onErr (a7c66c0)
    • The new indexed variants (onEachOkIndexed, onEachErrIndexed) proved that the Success/Failure naming becomes too verbose. Ok/Err is more readable.
  • Rename filterValues/filterErrors to filterOk/filterErr (87f4c36)
    • Aligns naming with existing allOk/allErr/anyOk/anyErr/countOk/countErr conventions
  • Add onEachOk, onEachOkIndexed, onEachErr, onEachErrIndexed for Iterable<Result> (a7c66c0)
  • Add combineErr and combineTo/combineErrTo for Iterable<Result> (1133e00, c06eeb3)
  • Propagate nested coroutineBinding failures by @dbottillo (d952b52)
  • Make BindingException public (549ed30)
    • Fixes 'internal' type accessed from public inline declaration warning that will become an error in Kotlin 2.4
  • Update Kotlin to 2.3.10 (12ceff7)
  • Update Gradle to 9.4.0 (468b1a5)