1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
The `Either` type, a.k.a. `σ`, is used to represent an _anonymous sum type_.
Similar to [`Cons`](crate::types::Cons), `Either` is used to form a sum type
by combining a chain of `Either` types, and terminated with a [`Void`] type.
But unlike product types, a sum type has values that belong to one
of the variants in the list.
`Either` is also shown as `σ`, together with [`Void`] shown as `θ`, to improve
the readability of compiler error messages. Through the shortened name, a sum
type would take slightly less space, making it more likely to fit on a single
line for the user to read what the type is.
`Either` is most often used through the `Sum!` macro, which accepts a list of
types and turns them into a chain of `Either` types.
## Example
Given the following sum type definition:
```rust,ignore
type MyUnion = Sum![u32, String, bool];
```
The following type would be generated:
```rust,ignore
type MyUnion = Either<u32, Either<String, Either<bool, Void>>>;
```
which would be shown with the shortened representation as:
```rust,ignore
type MyUnion = σ<u32, σ<String, σ<bool, θ>>>;
```
*/
/**
The `Void` type, a.k.a. `θ`, is used to represent the end of an _anonymous sum type_,
or an _empty_ sum type.
`Void` is commonly used as the `Tail` of a [`Either`] type, to terminate the list.
When used on its own, it represents an empty sum type, which can _never be constructed_.
`Void` is functionally the same as the
[_never_ type](https://doc.rust-lang.org/std/primitive.never.html), `!`,
or otherwise
[`Infallible`](https://doc.rust-lang.org/std/convert/enum.Infallible.html).
However, we define a separate `Void` type, to make it more clear that it is
specifically used for terminating a sum type.
Read more about sum types in [`Either`].
*/
pub use θ as Void;
pub use σ as Either;