|
1 | 1 | @file:Suppress("NAME_SHADOWING")
|
| 2 | + |
2 | 3 | package arrow.core
|
3 | 4 |
|
| 5 | +object Nullable { |
| 6 | + |
| 7 | + inline fun <A, R> mapN(a: A?, fn: (A) -> R): R? = |
| 8 | + mapN(a, Unit) { a, _ -> fn(a) } |
| 9 | + |
| 10 | + inline fun <A, B, R> mapN(a: A?, b: B?, fn: (A, B) -> R): R? = |
| 11 | + mapN(a, b, Unit) { a, b, _ -> fn(a, b) } |
| 12 | + |
| 13 | + inline fun <A, B, C, R> mapN(a: A?, b: B?, c: C?, fn: (A, B, C) -> R): R? = |
| 14 | + mapN(a, b, c, Unit) { a, b, c, _ -> fn(a, b, c) } |
| 15 | + |
| 16 | + inline fun <A, B, C, D, R> mapN(a: A?, b: B?, c: C?, d: D?, fn: (A, B, C, D) -> R): R? = |
| 17 | + mapN(a, b, c, d, Unit) { a, b, c, d, _ -> fn(a, b, c, d) } |
| 18 | + |
| 19 | + inline fun <A, B, C, D, E, R> mapN(a: A?, b: B?, c: C?, d: D?, e: E?, fn: (A, B, C, D, E) -> R): R? = |
| 20 | + mapN(a, b, c, d, e, Unit) { a, b, c, d, e, _ -> fn(a, b, c, d, e) } |
| 21 | + |
| 22 | + inline fun <A, B, C, D, E, F, R> mapN(a: A?, b: B?, c: C?, d: D?, e: E?, f: F?, fn: (A, B, C, D, E, F) -> R): R? = |
| 23 | + mapN(a, b, c, d, e, f, Unit) { a, b, c, d, e, f, _ -> fn(a, b, c, d, e, f) } |
| 24 | + |
| 25 | + inline fun <A, B, C, D, E, F, G, R> mapN(a: A?, b: B?, c: C?, d: D?, e: E?, f: F?, g: G?, fn: (A, B, C, D, E, F, G) -> R): R? = |
| 26 | + mapN(a, b, c, d, e, f, g, Unit) { a, b, c, d, e, f, g, _ -> fn(a, b, c, d, e, f, g) } |
| 27 | + |
| 28 | + inline fun <A, B, C, D, E, F, G, H, R> mapN(a: A?, b: B?, c: C?, d: D?, e: E?, f: F?, g: G?, h: H?, fn: (A, B, C, D, E, F, G, H) -> R): R? = |
| 29 | + mapN(a, b, c, d, e, f, g, h, Unit) { a, b, c, d, e, f, g, h, _ -> fn(a, b, c, d, e, f, g, h) } |
| 30 | + |
| 31 | + inline fun <A, B, C, D, E, F, G, H, I, R> mapN(a: A?, b: B?, c: C?, d: D?, e: E?, f: F?, g: G?, h: H?, i: I?, fn: (A, B, C, D, E, F, G, H, I) -> R): R? = |
| 32 | + a?.let { a -> |
| 33 | + b?.let { b -> |
| 34 | + c?.let { c -> |
| 35 | + d?.let { d -> |
| 36 | + e?.let { e -> |
| 37 | + f?.let { f -> |
| 38 | + g?.let { g -> |
| 39 | + h?.let { h -> |
| 40 | + i?.let { i -> |
| 41 | + fn(a, b, c, d, e, f, g, h, i) |
| 42 | + } |
| 43 | + } |
| 44 | + } |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +@Deprecated("Top-level mapN function for A? conflicts with other types such as List<A> and Map<K, V>", ReplaceWith("Nullable.mapN(a, fn", "arrow.core.mapN")) |
4 | 54 | inline fun <A, R> mapN(a: A?, fn: (A) -> R): R? =
|
5 |
| - mapN(a, Unit) { a, _ -> fn(a) } |
| 55 | + Nullable.mapN(a, fn) |
6 | 56 |
|
| 57 | +@Deprecated("Top-level mapN function for A? conflicts with other types such as List<A> and Map<K, V>", ReplaceWith("Nullable.mapN(a, b, fn", "arrow.core.mapN")) |
7 | 58 | inline fun <A, B, R> mapN(a: A?, b: B?, fn: (A, B) -> R): R? =
|
8 |
| - mapN(a, b, Unit) { a, b, _ -> fn(a, b) } |
| 59 | + Nullable.mapN(a, b, fn) |
9 | 60 |
|
| 61 | +@Deprecated("Top-level mapN function for A? conflicts with other types such as List<A> and Map<K, V>", ReplaceWith("Nullable.mapN(a, b, c, fn", "arrow.core.mapN")) |
10 | 62 | inline fun <A, B, C, R> mapN(a: A?, b: B?, c: C?, fn: (A, B, C) -> R): R? =
|
11 |
| - mapN(a, b, c, Unit) { a, b, c, _ -> fn(a, b, c) } |
| 63 | + Nullable.mapN(a, b, c, fn) |
12 | 64 |
|
| 65 | +@Deprecated("Top-level mapN function for A? conflicts with other types such as List<A> and Map<K, V>", ReplaceWith("Nullable.mapN(a, b, c, d, fn", "arrow.core.mapN")) |
13 | 66 | inline fun <A, B, C, D, R> mapN(a: A?, b: B?, c: C?, d: D?, fn: (A, B, C, D) -> R): R? =
|
14 |
| - mapN(a, b, c, d, Unit) { a, b, c, d, _ -> fn(a, b, c, d) } |
| 67 | + Nullable.mapN(a, b, c, d, fn) |
15 | 68 |
|
| 69 | +@Deprecated("Top-level mapN function for A? conflicts with other types such as List<A> and Map<K, V>", ReplaceWith("Nullable.mapN(a, b, c, d, e, fn", "arrow.core.mapN")) |
16 | 70 | inline fun <A, B, C, D, E, R> mapN(a: A?, b: B?, c: C?, d: D?, e: E?, fn: (A, B, C, D, E) -> R): R? =
|
17 |
| - mapN(a, b, c, d, e, Unit) { a, b, c, d, e, _ -> fn(a, b, c, d, e) } |
| 71 | + Nullable.mapN(a, b, c, d, e, fn) |
18 | 72 |
|
| 73 | +@Deprecated("Top-level mapN function for A? conflicts with other types such as List<A> and Map<K, V>", ReplaceWith("Nullable.mapN(a, b, c, d, e, f, fn", "arrow.core.mapN")) |
19 | 74 | inline fun <A, B, C, D, E, F, R> mapN(a: A?, b: B?, c: C?, d: D?, e: E?, f: F?, fn: (A, B, C, D, E, F) -> R): R? =
|
20 |
| - mapN(a, b, c, d, e, f, Unit) { a, b, c, d, e, f, _ -> fn(a, b, c, d, e, f) } |
| 75 | + Nullable.mapN(a, b, c, d, e, f, fn) |
21 | 76 |
|
| 77 | +@Deprecated("Top-level mapN function for A? conflicts with other types such as List<A> and Map<K, V>", ReplaceWith("Nullable.mapN(a, b, c, d, e, f, g, fn", "arrow.core.mapN")) |
22 | 78 | inline fun <A, B, C, D, E, F, G, R> mapN(a: A?, b: B?, c: C?, d: D?, e: E?, f: F?, g: G?, fn: (A, B, C, D, E, F, G) -> R): R? =
|
23 |
| - mapN(a, b, c, d, e, f, g, Unit) { a, b, c, d, e, f, g, _ -> fn(a, b, c, d, e, f, g) } |
| 79 | + Nullable.mapN(a, b, c, d, e, f, g, fn) |
24 | 80 |
|
| 81 | +@Deprecated("Top-level mapN function for A? conflicts with other types such as List<A> and Map<K, V>", ReplaceWith("Nullable.mapN(a, b, c, d, e, f, g, h, fn", "arrow.core.mapN")) |
25 | 82 | inline fun <A, B, C, D, E, F, G, H, R> mapN(a: A?, b: B?, c: C?, d: D?, e: E?, f: F?, g: G?, h: H?, fn: (A, B, C, D, E, F, G, H) -> R): R? =
|
26 |
| - mapN(a, b, c, d, e, f, g, h, Unit) { a, b, c, d, e, f, g, h, _ -> fn(a, b, c, d, e, f, g, h) } |
| 83 | + Nullable.mapN(a, b, c, d, e, f, g, h, fn) |
27 | 84 |
|
| 85 | +@Deprecated("Top-level mapN function for A? conflicts with other types such as List<A> and Map<K, V>", ReplaceWith("Nullable.mapN(a, b, c, d, e, f, g, h, i, fn", "arrow.core.mapN")) |
28 | 86 | inline fun <A, B, C, D, E, F, G, H, I, R> mapN(a: A?, b: B?, c: C?, d: D?, e: E?, f: F?, g: G?, h: H?, i: I?, fn: (A, B, C, D, E, F, G, H, I) -> R): R? =
|
29 |
| - a?.let { a -> |
30 |
| - b?.let { b -> |
31 |
| - c?.let { c -> |
32 |
| - d?.let { d -> |
33 |
| - e?.let { e -> |
34 |
| - f?.let { f -> |
35 |
| - g?.let { g -> |
36 |
| - h?.let { h -> |
37 |
| - i?.let { i -> |
38 |
| - fn(a, b, c, d, e, f, g, h, i) |
39 |
| - } |
40 |
| - } |
41 |
| - } |
42 |
| - } |
43 |
| - } |
44 |
| - } |
45 |
| - } |
46 |
| - } |
47 |
| - } |
| 87 | + Nullable.mapN(a, b, c, d, e, f, g, h, i, fn) |
0 commit comments