Type.Union (mavis v0.0.6) View Source

Represents the Union of two or more types.

The associated struct has one field:

  • :of which is a list of all types that are being unioned.

For performance purposes, Union keeps its subtypes in reverse-type-order.

Type.Union implements both the enumerable protocol and the collectable protocol; if you collect into a union, it will return a Type.t/0 result in general; it might not be a Type.Union struct:

iex> Enum.into([1, 3], %Type.Union{})
%Type.Union{of: [3, 1]}

iex> inspect %Type.Union{of: [3, 1]}
"1 | 3"

iex> Enum.into([1..10, 11..20], %Type.Union{})
1..20

Link to this section Summary

Link to this section Types

Specs

t() :: %Type.Union{of: [Type.t(), ...]}

Specs

t(type) :: %Type.Union{of: [type, ...]}

Link to this section Functions