However, sum types are easily implemented in a package. Here are some sample implementations.

```
struct Left{T}
val::T
end
struct Right{T}
val::T
end
const Sum{T, U} = Union{Left{T}, Right{U}}
```

or with a backing `Union`

:

```
struct Sum{T, U}
isleft::Bool
val::Union{T, U}
end
```

or with `Nullable`

:

```
struct Sum{T, U}
left::Nullable{T}
right::Nullable{U}
end
```

or with memory being shared, for primitive types of the same size:

```
struct IsBitsSum{T, U}
isleft::Bool
bits::T
end
unsafe_left(x::IsBitsSum) = x.bits
unsafe_right(x::IsBitsSum{<:Any, U}) where U = reinterpret(U, x.bits)
left(x::IsBitsSum) = (@argcheck x.isleft; unsafe_left(x))
right(x::IsBitsSum) = (@argcheck !x.isleft; unsafe_right(x))
get(x::IsBitsSum) = x.isleft ? unsafe_left(x) : unsafe_right(x)
```