Skip to content

Can constructors of a sum type be alias of variants? #77

@Tortar

Description

@Tortar

e.g. consider the sum type in the readme:

@sum_type AT begin
    A(common_field::Int, a::Bool, b::Int)
    B(common_field::Int, a::Int, b::Float64, d::Complex)
    C(common_field::Int, b::Float64, d::Bool, e::Float64, k::Complex{Real})
    D(common_field::Int, b::Any)
end

here A, B, C and D are just "fake types" used for making constructors for sum types. But I wonder why couldn't they be alias of the variants?

const A = SumTypes.Variant{:A, (:common_field, :a, :b), Tuple{Int64, Bool, Int64}}

this way the dispatch system will become available even for sum types, which is something it would be useful for things I plan to do in MixedStructTypes, but I think it would be good in general...this shouldn't be breaking right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions