• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Oct 19th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. typealias Either7<A, B, C, D, E, F, G> = Either<A, Either<B, Either<C, Either<D, Either<E, Either<F, G>>>>>>
2. typealias Either6<A, B, C, D, E, F> = Either7<A, B, C, D, E, F, Nothing>
3. typealias Either5<A, B, C, D, E> = Either7<A, B, C, D, E, Nothing, Nothing>
4. typealias Either4<A, B, C, D> = Either7<A, B, C, D, Nothing, Nothing, Nothing>
5. typealias Either3<A, B, C> = Either7<A, B, C, Nothing, Nothing, Nothing, Nothing>
6.
7. fun <A, B, C, D, E, F, G, R> Either7<A, B, C, D, E, F, G>.fold(
8.         ifa: (A) -> R,
9.         ifb: (B) -> R,
10.         ifc: (C) -> R,
11.         ifd: (D) -> R,
12.         ife: (E) -> R,
13.         iff: (F) -> R,
14.         ifg: (G) -> R
15. ) =
16.         fold(ifa, { b ->
17.             b.fold(ifb, { c ->
18.                 c.fold(ifc, { d ->
19.                     d.fold(ifd, { e ->
20.                         e.fold(ife, { f ->
21.                             f.fold(iff, ifg)
22.                         })
23.                     })
24.                 })
25.             })
26.         })
27.
28. fun <A, B, C, D, E, F, R> Either6<A, B, C, D, E, F>.fold(
29.         ifa: (A) -> R,
30.         ifb: (B) -> R,
31.         ifc: (C) -> R,
32.         ifd: (D) -> R,
33.         ife: (E) -> R,
34.         iff: (F) -> R
35. ) = fold(ifa, ifb, ifc, ifd, ife, iff, ::self)
36.
37.
38. fun <A, B, C, D, E, R> Either5<A, B, C, D, E>.fold(
39.         ifa: (A) -> R,
40.         ifb: (B) -> R,
41.         ifc: (C) -> R,
42.         ifd: (D) -> R,
43.         ife: (E) -> R
44. ) = fold(ifa, ifb, ifc, ifd, ife, ::self, ::self)
45.
46. fun <A, B, C, D, R> Either4<A, B, C, D>.fold(
47.         ifa: (A) -> R,
48.         ifb: (B) -> R,
49.         ifc: (C) -> R,
50.         ifd: (D) -> R
51. ) = fold(ifa, ifb, ifc, ifd, ::self, ::self, ::self)
52.
53. fun <A, B, C, R> Either3<A, B, C>.fold(
54.         ifa: (A) -> R,
55.         ifb: (B) -> R,
56.         ifc: (C) -> R
57. ) = fold(ifa, ifb, ifc, ::self, ::self, ::self, ::self)
58.
59. fun <A, B, C, D, E, F, G> Either7<A, B, C, D, E, F, G>.foldAny(): Any =
60.         fold({ it as Any },
61.                 { it as Any },
62.                 { it as Any },
63.                 { it as Any },
64.                 { it as Any },
65.                 { it as Any },
66.                 { it as Any })
67.
68. fun <A, B, C, D, E, F, G> A.variant1(): Either7<A, B, C, D, E, F, G> =
69.         Either.Left(this)
70.
71. fun <A, B, C, D, E, F, G> B.variant2(): Either7<A, B, C, D, E, F, G> =
72.         Either.Right(
73.                 Either.Left(this))
74.
75. fun <A, B, C, D, E, F, G> C.variant3(): Either7<A, B, C, D, E, F, G> =
76.         Either.Right(
77.                 Either.Right(
78.                         Either.Left(this)))
79.
80. fun <A, B, C, D, E, F, G> D.variant4(): Either7<A, B, C, D, E, F, G> =
81.         Either.Right(
82.                 Either.Right(
83.                         Either.Right(
84.                                 Either.Left(this))))
85.
86. fun <A, B, C, D, E, F, G> E.variant5(): Either7<A, B, C, D, E, F, G> =
87.         Either.Right(
88.                 Either.Right(
89.                         Either.Right(
90.                                 Either.Right(
91.                                         Either.Left(this)))))
92.
93. fun <A, B, C, D, E, F, G> F.variant6(): Either7<A, B, C, D, E, F, G> =
94.         Either.Right(
95.                 Either.Right(
96.                         Either.Right(
97.                                 Either.Right(
98.                                         Either.Right(
99.                                                 Either.Left(this))))))
100.
101. fun <A, B, C, D, E, F, G> G.variant7(): Either7<A, B, C, D, E, F, G> =
102.         Either.Right(
103.                 Either.Right(
104.                         Either.Right(
105.                                 Either.Right(
106.                                         Either.Right(
107.                                                 Either.Right(
108.                                                         this))))))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top