API
LightSumTypes.@sumtype — Macro@sumtype SumTypeName(Types) [<: AbstractType]Creates a sumtype composed by the given types. It optionally accept also an abstract supertype.
Example
julia> using LightSumTypes
julia> struct A x::Int end;
julia> struct B end;
julia> @sumtype AB(A, B)LightSumTypes.variant — Functionvariant(inst)Returns the variant enclosed in the sum type.
Example
julia> using LightSumTypes
julia> struct A x::Int end;
julia> struct B end;
julia> @sumtype AB(A, B)
julia> a = AB(A(0))
AB'.A(0)
julia> variant(a)
A(0)LightSumTypes.allvariants — Functionallvariants(SumType)Returns all the enclosed variants types in the sum type in a namedtuple.
Example
julia> using LightSumTypes
julia> struct A x::Int end;
julia> struct B end;
julia> @sumtype AB(A, B)
julia> allvariants(AB)
(A = A, B = B)LightSumTypes.variantof — Functionvariantof(inst)Returns the type of the variant enclosed in the sum type.
LightSumTypes.is_sumtype — Functionis_sumtype(T)Returns true if the type is a sum type otherwise returns false.