Like others I’m somewhat bothered by the long type signatures caused by missing data.
julia> using Missings
julia> A = [0.0+0im, missing]
2-element Array{Union{Complex{Float64}, Missings.Missing},1}:
0.0+0.0im
missing
So I coded an alternative.
# ⍰ \APLboxquestion<tab>
using Missings
for typ in [:Int64, :Float64, :AbstractString]
typq = Symbol(typ,'⍰')
@eval const $(typq) = Union{$(typ), Missing}
end
const Complex⍰{Float64} = Union{Complex{Float64}, Missings.Missing}
Base.show(io::IO, ::Type{Union{T, Missings.Missing}}) where T = begin
parms = isempty(T.parameters) ? "" : string('{', join(T.parameters,','), '}')
print(io, T.name.name, '⍰', parms)
end
Now I can write:
julia> [1.0+0im, missing]
2-element Array{Complex⍰{Float64},1}:
1.0+0.0im
missing
julia> Int64⍰[1,2]
2-element Array{Int64⍰,1}:
1
2
Are there reasons not to do this?