Module

# Data.Either.Nested

Package
purescript-either
Repository
purescript/purescript-either

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 (\/)Source

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

### #(\/)Source

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

The `\/` operator alias for the `either` function allows easy matching on nested Eithers. For example, consider the function

``````f :: (Int \/ String \/ Boolean) -> String
f (Left x) = show x
f (Right (Left y)) = y
f (Right (Right z)) = if z then "Yes" else "No"
``````

The `\/` operator alias allows us to rewrite this function as

``````f :: (Int \/ String \/ Boolean) -> String
f = show \/ identity \/ if _ then "Yes" else "No"
``````

### #in1Source

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

### #in2Source

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

### #in3Source

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

### #in4Source

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

### #in5Source

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

### #in6Source

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

### #in7Source

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

### #in8Source

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

### #in9Source

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

### #in10Source

``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``

### #at1Source

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

### #at2Source

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

### #at3Source

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

### #at4Source

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

### #at5Source

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

### #at6Source

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

### #at7Source

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

### #at8Source

``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``

### #at9Source

``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``

### #at10Source

``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``

### #Either1Source

``type Either1 a = a \/ Void``

### #Either2Source

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

### #Either3Source

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

### #Either4Source

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

### #Either5Source

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

### #Either6Source

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

### #Either7Source

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

### #Either8Source

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

### #Either9Source

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

### #Either10Source

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

### #either1Source

``either1 :: forall a. Either1 a -> a``

### #either2Source

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

### #either3Source

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

### #either4Source

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

### #either5Source

``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``

### #either6Source

``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``

### #either7Source

``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``

### #either8Source

``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``

### #either9Source

``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``

### #either10Source

``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``