1+ -- | Utilities for n-eithers: sums types with more than two terms built from nested eithers.
2+ -- |
3+ -- | Nested eithers arise naturally in sum combinators. You shouldn't
4+ -- | represent sum data using nested eithers, but if combinators you're working with
5+ -- | create them, utilities in this module will allow to to more easily work
6+ -- | with them, including translating to and from more traditional sum types.
7+ -- |
8+ -- | ```purescript
9+ -- | data Color = Red Number | Green Number | Blue Number
10+ -- |
11+ -- | toEither3 :: Color -> Either3 Number Number Number
12+ -- | toEither3 = either3 Red Green Blue
13+ -- |
14+ -- | fromEither3 :: Either3 Number Number Number -> Color
15+ -- | fromEither3 (Red v) = either1of3
16+ -- | fromEither3 (Green v) = either2of3
17+ -- | fromEither3 (Blue v) = either3of3
18+ -- | ```
119module Data.Either.Nested where
220 import Data.Either
321
@@ -11,6 +29,177 @@ module Data.Either.Nested where
1129 type Either9 a b c d e f g h z = Either (Either8 a b c d e f g h ) z
1230 type Either10 a b c d e f g h i z = Either (Either9 a b c d e f g h i ) z
1331
32+ -- Either2
33+ either1of2 :: forall a b. a -> Either2 a b
34+ either1of2 = Left
35+
36+ either2of2 :: forall a b. b -> Either2 a b
37+ either2of2 = Right
38+
39+ -- Either3
40+ either1of3 = forall a b c. a -> Either3 a b c
41+ either1of3 v = (Left (Left v))
42+
43+ either2of3 = forall a b c. b -> Either3 a b c
44+ either2of3 v = (Left (Right v))
45+
46+ either3of3 = forall a b c. c -> Either3 a b c
47+ either3of3 v = Right v
48+
49+ -- Either4
50+ either1of4 = forall a b c d. a -> Either4 a b c d
51+ either1of4 v = (Left (Left (Left v)))
52+
53+ either2of4 = forall a b c d. b -> Either4 a b c d
54+ either2of4 v = (Left (Left (Right v)))
55+
56+ either3of4 = forall a b c d. c -> Either4 a b c d
57+ either3of4 v = (Left (Right v))
58+
59+ either4of4 = forall a b c d. d -> Either4 a b c d
60+ either4of4 v = Right v
61+
62+ -- Either5
63+ either1of5 = forall a b c d e. a -> Either5 a b c d e
64+ either1of5 v = (Left (Left (Left (Left v))))
65+
66+ either2of5 = forall a b c d e. b -> Either5 a b c d e
67+ either2of5 v = (Left (Left (Left (Right v))))
68+
69+ either3of5 = forall a b c d e. c -> Either5 a b c d e
70+ either3of5 v = (Left (Left (Right v)))
71+
72+ either4of5 = forall a b c d e. d -> Either5 a b c d e
73+ either4of5 v = (Left (Right v))
74+
75+ either5of5 = forall a b c d e. e -> Either5 a b c d e
76+ either5of5 v = Right v
77+
78+ -- Either6
79+ either1of6 = forall a b c d e f. a -> Either6 a b c d e f
80+ either1of6 v = (Left (Left (Left (Left (Left v)))))
81+
82+ either2of6 = forall a b c d e f. b -> Either6 a b c d e f
83+ either2of6 v = (Left (Left (Left (Left (Right v)))))
84+
85+ either3of6 = forall a b c d e f. c -> Either6 a b c d e f
86+ either3of6 v = (Left (Left (Left (Right v))))
87+
88+ either4of6 = forall a b c d e f. d -> Either6 a b c d e f
89+ either4of6 v = (Left (Left (Right v)))
90+
91+ either5of6 = forall a b c d e f. e -> Either6 a b c d e f
92+ either5of6 v = (Left (Right v))
93+
94+ either6of6 = forall a b c d e f. f -> Either6 a b c d e f
95+ either6of6 v = Right v
96+
97+ -- Either7
98+ either1of7 = forall a b c d e f g. a -> Either7 a b c d e f g
99+ either1of7 v = (Left (Left (Left (Left (Left (Left v))))))
100+
101+ either2of7 = forall a b c d e f g. b -> Either7 a b c d e f g
102+ either2of7 v = (Left (Left (Left (Left (Left (Right v))))))
103+
104+ either3of7 = forall a b c d e f g. c -> Either7 a b c d e f g
105+ either3of7 v = (Left (Left (Left (Left (Right v)))))
106+
107+ either4of7 = forall a b c d e f g. d -> Either7 a b c d e f g
108+ either4of7 v = (Left (Left (Left (Right v))))
109+
110+ either5of7 = forall a b c d e f g. e -> Either7 a b c d e f g
111+ either5of7 v = (Left (Left (Right v)))
112+
113+ either6of7 = forall a b c d e f g. f -> Either7 a b c d e f g
114+ either6of7 v = (Left (Right v))
115+
116+ either7of7 = forall a b c d e f g. g -> Either7 a b c d e f g
117+ either7of7 v = Right v
118+
119+ -- Either8
120+ either1of8 = forall a b c d e f g h. a -> Either8 a b c d e f g h
121+ either1of8 v = (Left (Left (Left (Left (Left (Left (Left v)))))))
122+
123+ either2of8 = forall a b c d e f g h. b -> Either8 a b c d e f g h
124+ either2of8 v = (Left (Left (Left (Left (Left (Left (Right v)))))))
125+
126+ either3of8 = forall a b c d e f g h. c -> Either8 a b c d e f g h
127+ either3of8 v = (Left (Left (Left (Left (Left (Right v))))))
128+
129+ either4of8 = forall a b c d e f g h. d -> Either8 a b c d e f g h
130+ either4of8 v = (Left (Left (Left (Left (Right v)))))
131+
132+ either5of8 = forall a b c d e f g h. e -> Either8 a b c d e f g h
133+ either5of8 v = (Left (Left (Left (Right v))))
134+
135+ either6of8 = forall a b c d e f g h. f -> Either8 a b c d e f g h
136+ either6of8 v = (Left (Left (Right v)))
137+
138+ either7of8 = forall a b c d e f g h. g -> Either8 a b c d e f g h
139+ either7of8 v = (Left (Right v))
140+
141+ either8of8 = forall a b c d e f g h. h -> Either8 a b c d e f g h
142+ either8of8 v = Right v
143+
144+ -- Either9
145+ either1of9 = forall a b c d e f g h i. a -> Either9 a b c d e f g h i
146+ either1of9 v = (Left (Left (Left (Left (Left (Left (Left (Left v)))))))))
147+
148+ either2of9 = forall a b c d e f g h i. b -> Either9 a b c d e f g h i
149+ either2of9 v = (Left (Left (Left (Left (Left (Left (Left (Right v)))))))))
150+
151+ either3of9 = forall a b c d e f g h i. c -> Either9 a b c d e f g h i
152+ either3of9 v = (Left (Left (Left (Left (Left (Left (Right v))))))))
153+
154+ either4of9 = forall a b c d e f g h i. d -> Either9 a b c d e f g h i
155+ either4of9 v = (Left (Left (Left (Left (Left (Right v)))))))
156+
157+ either5of9 = forall a b c d e f g h i. e -> Either9 a b c d e f g h i
158+ either5of9 v = (Left (Left (Left (Left (Right v))))))
159+
160+ either6of9 = forall a b c d e f g h i. f -> Either9 a b c d e f g h i
161+ either6of9 v = (Left (Left (Left (Right v)))))
162+
163+ either7of9 = forall a b c d e f g h i. g -> Either9 a b c d e f g h i
164+ either7of9 v = (Left (Left (Right v))))
165+
166+ either8of9 = forall a b c d e f g h i. h -> Either9 a b c d e f g h i
167+ either8of9 v = (Left (Right v)))
168+
169+ either9of9 = forall a b c d e f g h i. i -> Either9 a b c d e f g h i
170+ either9of9 v = Right v
171+
172+ -- Either10
173+ either1of10 = forall a b c d e f g h i j. a -> Either10 a b c d e f g h i j
174+ either1of10 v = (Left (Left (Left (Left (Left (Left (Left (Left (Left v))))))))))
175+
176+ either2of10 = forall a b c d e f g h i j. b -> Either10 a b c d e f g h i j
177+ either2of10 v = (Left (Left (Left (Left (Left (Left (Left (Left (Right v))))))))))
178+
179+ either3of10 = forall a b c d e f g h i j. c -> Either10 a b c d e f g h i j
180+ either3of10 v = (Left (Left (Left (Left (Left (Left (Left (Right v)))))))))
181+
182+ either4of10 = forall a b c d e f g h i j. d -> Either10 a b c d e f g h i j
183+ either4of10 v = (Left (Left (Left (Left (Left (Left (Right v))))))))
184+
185+ either5of10 = forall a b c d e f g h i j. e -> Either10 a b c d e f g h i j
186+ either5of10 v = (Left (Left (Left (Left (Left (Right v)))))))
187+
188+ either6of10 = forall a b c d e f g h i j. f -> Either10 a b c d e f g h i j
189+ either6of10 v = (Left (Left (Left (Left (Right v))))))
190+
191+ either7of10 = forall a b c d e f g h i j. g -> Either10 a b c d e f g h i j
192+ either7of10 v = (Left (Left (Left (Right v)))))
193+
194+ either8of10 = forall a b c d e f g h i j. h -> Either10 a b c d e f g h i j
195+ either8of10 v = (Left (Left (Right v))))
196+
197+ either9of10 = forall a b c d e f g h i j. i -> Either10 a b c d e f g h i j
198+ either9of10 v = (Left (Right v)))
199+
200+ either10of10 = forall a b c d e f g h i j. j -> Either10 a b c d e f g h i j
201+ either10of10 v = Right v
202+
14203 either2 :: forall a b z. (a -> z ) -> (b -> z ) -> Either2 a b -> z
15204 either2 = either
16205
0 commit comments