diff --git a/Project.toml b/Project.toml index 88fd9e4..a92fde3 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "LightSumTypes" uuid = "f56206fc-af4c-5561-a72a-43fe2ca5a923" -version = "4.1.0" +version = "4.2.0" [deps] ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04" diff --git a/src/LightSumTypes.jl b/src/LightSumTypes.jl index a161c80..c9c3642 100644 --- a/src/LightSumTypes.jl +++ b/src/LightSumTypes.jl @@ -65,9 +65,13 @@ function sumtype_expr(typedef) constructors = [:(@inline $(namify(type))(v::Union{$(variants...)}) where {$(typeparams...)} = $(branchs(variants, variants_with_P, :(return new{$(typeparams...)}(v)))...))] - constructors_extra = [:($Base.adjoint(SumT::Type{$typename}) = $(Expr(:tuple, (:($nv = (args...; kwargs...) -> - $LightSumTypes.constructor($typename, $v, args...; kwargs...)) for (nv, v) in - zip(variants_names, variants_bounded))...)))] + constructors_extra = [:(function $Base.adjoint(SumT::Type{$typename}) + @warn "Using A'.B syntax is deprecated in favour of the native A∘B syntax; \ + the functionality will be removed in a future release of the package" + return $(Expr(:tuple, (:($nv = (args...; kwargs...) -> + $LightSumTypes.constructor($typename, $v, args...; kwargs...)) for (nv, v) in + zip(variants_names, variants_bounded))...)) + end)] if type isa Expr push!( @@ -77,9 +81,12 @@ function sumtype_expr(typedef) ) push!( constructors_extra, - :($Base.adjoint(SumT::Type{$type}) where {$(typeparams...)} = - $(Expr(:tuple, (:($nv = (args...; kwargs...) -> $LightSumTypes.constructor($type, $v, args...; kwargs...)) - for (nv, v) in zip(variants_names, variants))...))) + :(function $Base.adjoint(SumT::Type{$type}) where {$(typeparams...)} + @warn "Using A'.B syntax is deprecated in favour of the native A∘B syntax; \ + the functionality will be removed in a future release of the package" + return $(Expr(:tuple, (:($nv = (args...; kwargs...) -> $LightSumTypes.constructor($type, $v, args...; kwargs...)) + for (nv, v) in zip(variants_names, variants))...)) + end) ) end