Julia's type system : what am I missing?

Adding to @Daniel_Berge 's answer, you can easily dispatch on more specific aliases:

const Len{T} = Quantity{T,u"𝐋"}
const Met{T} = Quantity{T,u"𝐋",typeof(m)}
const Deg{T} = Quantity{T,NoDims,typeof(Β°)}
const Rad{T} = Quantity{T,NoDims,typeof(rad)}

You don’t need to construct concrete Unitful.jl types for dispatch. And you can let Julia figure out the exact type in a field using a type parameter:

struct Foo{L<:Met}
  len::L
end
5 Likes