Utilities for n-eithers: sums types with more than two terms built from nested eithers.
Nested eithers arise naturally in sum combinators. You shouldn't represent sum data using nested eithers, but if combinators you're working with create them, utilities in this module will allow to to more easily work with them, including translating to and from more traditional sum types.
data Color = Red Number | Green Number | Blue Number
toEither3 :: Color -> Either3 Number Number Number
toEither3 = either3 Red Green Blue
fromEither3 :: Either3 Number Number Number -> Color
fromEither3 (Red v) = either1of3
fromEither3 (Green v) = either2of3
fromEither3 (Blue v) = either3of3type Either2 a z = Either a ztype Either3 a b z = Either (Either2 a b) ztype Either4 a b c z = Either (Either3 a b c) ztype Either5 a b c d z = Either (Either4 a b c d) ztype Either6 a b c d e z = Either (Either5 a b c d e) ztype Either7 a b c d e f z = Either (Either6 a b c d e f) ztype Either8 a b c d e f g z = Either (Either7 a b c d e f g) ztype Either9 a b c d e f g h z = Either (Either8 a b c d e f g h) ztype Either10 a b c d e f g h i z = Either (Either9 a b c d e f g h i) zeither1of2 :: forall a b. a -> Either2 a beither2of2 :: forall a b. b -> Either2 a beither1of3 :: forall a b c. a -> Either3 a b ceither2of3 :: forall a b c. b -> Either3 a b ceither3of3 :: forall a b c. c -> Either3 a b ceither1of4 :: forall a b c d. a -> Either4 a b c deither2of4 :: forall a b c d. b -> Either4 a b c deither3of4 :: forall a b c d. c -> Either4 a b c deither4of4 :: forall a b c d. d -> Either4 a b c deither1of5 :: forall a b c d e. a -> Either5 a b c d eeither2of5 :: forall a b c d e. b -> Either5 a b c d eeither3of5 :: forall a b c d e. c -> Either5 a b c d eeither4of5 :: forall a b c d e. d -> Either5 a b c d eeither5of5 :: forall a b c d e. e -> Either5 a b c d eeither1of6 :: forall a b c d e f. a -> Either6 a b c d e feither2of6 :: forall a b c d e f. b -> Either6 a b c d e feither3of6 :: forall a b c d e f. c -> Either6 a b c d e feither4of6 :: forall a b c d e f. d -> Either6 a b c d e feither5of6 :: forall a b c d e f. e -> Either6 a b c d e feither6of6 :: forall a b c d e f. f -> Either6 a b c d e feither1of7 :: forall a b c d e f g. a -> Either7 a b c d e f geither2of7 :: forall a b c d e f g. b -> Either7 a b c d e f geither3of7 :: forall a b c d e f g. c -> Either7 a b c d e f geither4of7 :: forall a b c d e f g. d -> Either7 a b c d e f geither5of7 :: forall a b c d e f g. e -> Either7 a b c d e f geither6of7 :: forall a b c d e f g. f -> Either7 a b c d e f geither7of7 :: forall a b c d e f g. g -> Either7 a b c d e f geither1of8 :: forall a b c d e f g h. a -> Either8 a b c d e f g heither2of8 :: forall a b c d e f g h. b -> Either8 a b c d e f g heither3of8 :: forall a b c d e f g h. c -> Either8 a b c d e f g heither4of8 :: forall a b c d e f g h. d -> Either8 a b c d e f g heither5of8 :: forall a b c d e f g h. e -> Either8 a b c d e f g heither6of8 :: forall a b c d e f g h. f -> Either8 a b c d e f g heither7of8 :: forall a b c d e f g h. g -> Either8 a b c d e f g heither8of8 :: forall a b c d e f g h. h -> Either8 a b c d e f g heither1of9 :: forall a b c d e f g h i. a -> Either9 a b c d e f g h ieither2of9 :: forall a b c d e f g h i. b -> Either9 a b c d e f g h ieither3of9 :: forall a b c d e f g h i. c -> Either9 a b c d e f g h ieither4of9 :: forall a b c d e f g h i. d -> Either9 a b c d e f g h ieither5of9 :: forall a b c d e f g h i. e -> Either9 a b c d e f g h ieither6of9 :: forall a b c d e f g h i. f -> Either9 a b c d e f g h ieither7of9 :: forall a b c d e f g h i. g -> Either9 a b c d e f g h ieither8of9 :: forall a b c d e f g h i. h -> Either9 a b c d e f g h ieither9of9 :: forall a b c d e f g h i. i -> Either9 a b c d e f g h ieither1of10 :: forall a b c d e f g h i j. a -> Either10 a b c d e f g h i jeither2of10 :: forall a b c d e f g h i j. b -> Either10 a b c d e f g h i jeither3of10 :: forall a b c d e f g h i j. c -> Either10 a b c d e f g h i jeither4of10 :: forall a b c d e f g h i j. d -> Either10 a b c d e f g h i jeither5of10 :: forall a b c d e f g h i j. e -> Either10 a b c d e f g h i jeither6of10 :: forall a b c d e f g h i j. f -> Either10 a b c d e f g h i jeither7of10 :: forall a b c d e f g h i j. g -> Either10 a b c d e f g h i jeither8of10 :: forall a b c d e f g h i j. h -> Either10 a b c d e f g h i jeither9of10 :: forall a b c d e f g h i j. i -> Either10 a b c d e f g h i jeither10of10 :: forall a b c d e f g h i j. j -> Either10 a b c d e f g h i jeither2 :: forall a b z. (a -> z) -> (b -> z) -> Either2 a b -> zeither3 :: forall a b c z. (a -> z) -> (b -> z) -> (c -> z) -> Either3 a b c -> zeither4 :: forall a b c d z. (a -> z) -> (b -> z) -> (c -> z) -> (d -> z) -> Either4 a b c d -> zeither5 :: forall a b c d e z. (a -> z) -> (b -> z) -> (c -> z) -> (d -> z) -> (e -> z) -> Either5 a b c d e -> zeither6 :: forall a b c d e f z. (a -> z) -> (b -> z) -> (c -> z) -> (d -> z) -> (e -> z) -> (f -> z) -> Either6 a b c d e f -> zeither7 :: forall a b c d e f g z. (a -> z) -> (b -> z) -> (c -> z) -> (d -> z) -> (e -> z) -> (f -> z) -> (g -> z) -> Either7 a b c d e f g -> zeither8 :: forall a b c d e f g h z. (a -> z) -> (b -> z) -> (c -> z) -> (d -> z) -> (e -> z) -> (f -> z) -> (g -> z) -> (h -> z) -> Either8 a b c d e f g h -> zeither9 :: forall a b c d e f g h i z. (a -> z) -> (b -> z) -> (c -> z) -> (d -> z) -> (e -> z) -> (f -> z) -> (g -> z) -> (h -> z) -> (i -> z) -> Either9 a b c d e f g h i -> zeither10 :: forall a b c d e f g h i j z. (a -> z) -> (b -> z) -> (c -> z) -> (d -> z) -> (e -> z) -> (f -> z) -> (g -> z) -> (h -> z) -> (i -> z) -> (j -> z) -> Either10 a b c d e f g h i j -> z