Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Tortar opened this issue May 3, 2024 · 1 comment
Closed

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

Tortar opened this issue May 3, 2024 · 1 comment

Comments

@Tortar
Copy link
Contributor

Tortar commented May 3, 2024

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?

@Tortar
Copy link
Contributor Author

Tortar commented May 4, 2024

ok, this is not useful because it is not possible to dispatch the instances anyway because they are wrapped

@Tortar Tortar closed this as completed May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant