Created
December 14, 2021 14:50
-
-
Save nomisRev/85a1762729dbd80df87122160dbca2a0 to your computer and use it in GitHub Desktop.
Example of Arity-18 for Validated
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
/** | |
* In Arrow we only provide functions up to arity-9, | |
* using Tuple we can easily compose up to arity-n. | |
* | |
* A small example to show Validated#zip for arity-18 | |
*/ | |
fun validated(): ValidatedNel<String, Int> = | |
"example".invalidNel() | |
validated().zip( | |
validated(), | |
validated(), | |
validated(), | |
validated(), | |
validated(), | |
validated(), | |
validated(), | |
validated(), | |
::Tuple9 | |
).zip( | |
validated(), | |
validated(), | |
validated(), | |
validated(), | |
validated(), | |
validated(), | |
validated(), | |
validated() | |
) { (a, b, c, d, e, f, g, h, i), j, k, l, m, n, o, p, q, r -> | |
// Consume 18 validated values | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment