Module

Data.Either.Nested

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

fromEither3 :: Either3 Number Number Number -> Color
fromEither3 = either3 Red Green Blue

toEither3 :: Color -> Either3 Number Number Number
toEither3 (Red   v) = in1 v
toEither3 (Green v) = in2 v
toEither3 (Blue  v) = in3 v

#type (\/)

Operator alias for Data.Either.Either (right-associative / precedence 6)

#in1

in1 :: forall a z. a -> a \/ z

#in2

in2 :: forall a b z. b -> a \/ b \/ z

#in3

in3 :: forall a b c z. c -> a \/ b \/ c \/ z

#in4

in4 :: forall a b c d z. d -> a \/ b \/ c \/ d \/ z

#in5

in5 :: forall a b c d e z. e -> a \/ b \/ c \/ d \/ e \/ z

#in6

in6 :: forall a b c d e f z. f -> a \/ b \/ c \/ d \/ e \/ f \/ z

#in7

in7 :: forall a b c d e f g z. g -> a \/ b \/ c \/ d \/ e \/ f \/ g \/ z

#in8

in8 :: forall a b c d e f g h z. h -> a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ z

#in9

in9 :: forall a b c d e f g h i z. i -> a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ i \/ z

#in10

in10 :: forall a b c d e f g h i j z. j -> a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ i \/ j \/ z

#at1

at1 :: forall r a z. r -> (a -> r) -> a \/ z -> r

#at2

at2 :: forall r a b z. r -> (b -> r) -> a \/ b \/ z -> r

#at3

at3 :: forall r a b c z. r -> (c -> r) -> a \/ b \/ c \/ z -> r

#at4

at4 :: forall r a b c d z. r -> (d -> r) -> a \/ b \/ c \/ d \/ z -> r

#at5

at5 :: forall r a b c d e z. r -> (e -> r) -> a \/ b \/ c \/ d \/ e \/ z -> r

#at6

at6 :: forall r a b c d e f z. r -> (f -> r) -> a \/ b \/ c \/ d \/ e \/ f \/ z -> r

#at7

at7 :: forall r a b c d e f g z. r -> (g -> r) -> a \/ b \/ c \/ d \/ e \/ f \/ g \/ z -> r

#at8

at8 :: forall r a b c d e f g h z. r -> (h -> r) -> a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ z -> r

#at9

at9 :: forall r a b c d e f g h i z. r -> (i -> r) -> a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ i \/ z -> r

#at10

at10 :: forall r a b c d e f g h i j z. r -> (j -> r) -> a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ i \/ j \/ z -> r

#Either1

type Either1 a = a \/ Void

#Either2

type Either2 a b = a \/ b \/ Void

#Either3

type Either3 a b c = a \/ b \/ c \/ Void

#Either4

type Either4 a b c d = a \/ b \/ c \/ d \/ Void

#Either5

type Either5 a b c d e = a \/ b \/ c \/ d \/ e \/ Void

#Either6

type Either6 a b c d e f = a \/ b \/ c \/ d \/ e \/ f \/ Void

#Either7

type Either7 a b c d e f g = a \/ b \/ c \/ d \/ e \/ f \/ g \/ Void

#Either8

type Either8 a b c d e f g h = a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ Void

#Either9

type Either9 a b c d e f g h i = a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ i \/ Void

#Either10

type Either10 a b c d e f g h i j = a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ i \/ j \/ Void

#either1

either1 :: forall a. Either1 a -> a

#either2

either2 :: forall r a b. (a -> r) -> (b -> r) -> Either2 a b -> r

#either3

either3 :: forall r a b c. (a -> r) -> (b -> r) -> (c -> r) -> Either3 a b c -> r

#either4

either4 :: forall r a b c d. (a -> r) -> (b -> r) -> (c -> r) -> (d -> r) -> Either4 a b c d -> r

#either5

either5 :: forall r a b c d e. (a -> r) -> (b -> r) -> (c -> r) -> (d -> r) -> (e -> r) -> Either5 a b c d e -> r

#either6

either6 :: forall r a b c d e f. (a -> r) -> (b -> r) -> (c -> r) -> (d -> r) -> (e -> r) -> (f -> r) -> Either6 a b c d e f -> r

#either7

either7 :: forall r a b c d e f g. (a -> r) -> (b -> r) -> (c -> r) -> (d -> r) -> (e -> r) -> (f -> r) -> (g -> r) -> Either7 a b c d e f g -> r

#either8

either8 :: forall r a b c d e f g h. (a -> r) -> (b -> r) -> (c -> r) -> (d -> r) -> (e -> r) -> (f -> r) -> (g -> r) -> (h -> r) -> Either8 a b c d e f g h -> r

#either9

either9 :: forall r a b c d e f g h i. (a -> r) -> (b -> r) -> (c -> r) -> (d -> r) -> (e -> r) -> (f -> r) -> (g -> r) -> (h -> r) -> (i -> r) -> Either9 a b c d e f g h i -> r

#either10

either10 :: forall r a b c d e f g h i j. (a -> r) -> (b -> r) -> (c -> r) -> (d -> r) -> (e -> r) -> (f -> r) -> (g -> r) -> (h -> r) -> (i -> r) -> (j -> r) -> Either10 a b c d e f g h i j -> r

Modules