dev.forkhandles.result4k.flatZip.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of result4k Show documentation
Show all versions of result4k Show documentation
A friendly Kotlin Result type
package dev.forkhandles.result4k
inline fun flatZip(
r1: Result,
transform: (T1) -> Result
): Result =
r1.flatMap(transform)
inline fun flatZip(
r1: Result,
r2: Result,
transform: (T1, T2) -> Result
): Result =
r1.flatMap { v1 ->
r2.flatMap { v2 ->
transform(v1, v2)
}
}
inline fun flatZip(
r1: Result,
r2: Result,
r3: Result,
transform: (T1, T2, T3) -> Result
): Result =
r1.flatMap { v1 ->
r2.flatMap { v2 ->
r3.flatMap { v3 ->
transform(v1, v2, v3)
}
}
}
inline fun flatZip(
r1: Result,
r2: Result,
r3: Result,
r4: Result,
transform: (T1, T2, T3, T4) -> Result
): Result =
r1.flatMap { v1 ->
r2.flatMap { v2 ->
r3.flatMap { v3 ->
r4.flatMap { v4 ->
transform(v1, v2, v3, v4)
}
}
}
}
inline fun flatZip(
r1: Result,
r2: Result,
r3: Result,
r4: Result,
r5: Result,
transform: (T1, T2, T3, T4, T5) -> Result
): Result =
r1.flatMap { v1 ->
r2.flatMap { v2 ->
r3.flatMap { v3 ->
r4.flatMap { v4 ->
r5.flatMap { v5 ->
transform(v1, v2, v3, v4, v5)
}
}
}
}
}
inline fun flatZip(
r1: Result,
r2: Result,
r3: Result,
r4: Result,
r5: Result,
r6: Result,
transform: (T1, T2, T3, T4, T5, T6) -> Result
): Result =
r1.flatMap { v1 ->
r2.flatMap { v2 ->
r3.flatMap { v3 ->
r4.flatMap { v4 ->
r5.flatMap { v5 ->
r6.flatMap { v6 ->
transform(v1, v2, v3, v4, v5, v6)
}
}
}
}
}
}