-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
When defining sum types inside modules, arguably it would be desirable to be able to use the module prefix in order to make it clear where they are coming from. However, this currently does not seem to work:
julia> module MySumTypes
using SumTypes
@sum_type MySumType begin
Variant1
Variant2
end
end
Main.MySumTypes
julia> using .MySumTypes, SumTypes
julia> a = MySumTypes.Variant1
Variant1::MySumType
julia> @cases a begin
Variant1 => 1
Variant2 => 2
end
1
julia> @cases a begin
MySumTypes.Variant1 => 1
MySumTypes.Variant2 => 2
end
ERROR: LoadError: Invalid variant MySumTypes.Variant1
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] (::SumTypes.var"#69#72"{Expr, Base.RefValue{Any}, Vector{Any}})(::Tuple{Int64, Expr})
@ SumTypes ~/.julia/packages/SumTypes/aO6qd/src/cases.jl:69
[3] foreach(f::SumTypes.var"#69#72"{Expr, Base.RefValue{Any}, Vector{Any}}, itr::Base.Iterators.Enumerate{Vector{Any}})
@ Base ./abstractarray.jl:3187
[4] _cases(to_match::Symbol, block::Expr)
@ SumTypes ~/.julia/packages/SumTypes/aO6qd/src/cases.jl:35
[5] var"@cases"(__source__::LineNumberNode, __module__::Module, to_match::Any, block::Any)
@ SumTypes ~/.julia/packages/SumTypes/aO6qd/src/cases.jl:22
in expression starting at REPL[29]:1Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels