How about just breaking up the where clauses in to more understandable blocks? One nice feature of Julia v0.6 is that we now have a syntax for talking about these sorts of “unionall” types:
julia> using Unitful, AxisArrays
julia> const QAxis{Name, Dim} = Axis{Name, AX} where AX <: AbstractArray{Q} where Q <: Dim;
julia> const TimeAxis = QAxis{:time, Unitful.Time};
julia> const TimeArray{T, N, V} = AxisArray{T, N, V, <:NTuple{N, TimeAxis}};
julia> const TimeVector{T, V} = TimeArray{T, 1, V};
julia> test(a::TimeVector) = println("representing time")
test (generic function with 1 method)
julia> atime = AxisArray(collect(1:10), Axis{:time}((0:1:9)*u"ns"));
julia> test(atime)
representing time
julia> const EnergyAxis = QAxis{:energy, Unitful.Energy};
julia> const EnergyArray{T, N, V} = AxisArray{T, N, V, <:NTuple{N, EnergyAxis}};
julia> const EnergyVector{T, V} = EnergyArray{T, 1, V};
julia> test(a::EnergyVector) = println("representing energy")
test (generic function with 2 methods)
julia> aenergy = AxisArray(collect(1:10), Axis{:energy}((0:1:9)*u"eV"));
julia> test(aenergy)
representing energy
Or, if that’s too complicated, you can create whatever shorthand you want:
julia> using Unitful, AxisArrays
julia> const UnitfulVector{Name, Dim, T, V} = AxisArray{T, 1, V, Tuple{A}} where A <: Axis{Name, AX} where AX <: AbstractArray{Q} where Q <: Dim
AxisArrays.AxisArray{T,1,V,Tuple{A}} where A<:AxisArrays.Axis{Name,AX} where AX<:(AbstractArray{Q,N} where N) where Q<:Dim where V where T where Dim where Name
julia> function test(a::UnitfulVector{:time, Unitful.Time, T, V}) where {T, V}
println("representing time")
end
test (generic function with 1 method)
julia> atime = AxisArray(collect(1:10), Axis{:time}((0:1:9)*u"ns"));
julia> test(atime)
representing time
# if you want, you can even omit `T` and `V`:
julia> function test(a::UnitfulVector{:energy, Unitful.Energy})
println("representing energy")
end
test (generic function with 2 methods)
julia> aenergy = AxisArray(collect(1:10), Axis{:energy}((0:1:9)*u"eV"));
julia> test(aenergy)
representing energy
or if you don’t care about the name of the axis, but just its units:
julia> using Unitful, AxisArrays
julia> const UnitfulVector{Dim, T, V} = AxisArray{T, 1, V, Tuple{A}} where {Q <: Dim, AX <: AbstractArray{Q}, Name, A <: Axis{Name, AX}}
AxisArrays.AxisArray{T,1,V,Tuple{A}} where A<:AxisArrays.Axis{Name,AX} where Name where AX<:(AbstractArray{Q,N} where N) where Q<:Dim where V where T where Dim
julia> function test(a::UnitfulVector{Unitful.Energy})
println("representing energy")
end
test (generic function with 1 method)
julia> aenergy = AxisArray(collect(1:10), Axis{:energy}((0:1:9)*u"eV"));
julia> test(aenergy)
representing energy
julia> function test(a::UnitfulVector{Unitful.Time, T, V}) where {T, V}
println("representing time")
end
test (generic function with 2 methods)
julia> atime = AxisArray(collect(1:10), Axis{:time}((0:1:9)*u"ns"));
julia> test(atime)
representing time