How to dispatch on non-vararg Tuple types

Is it possible? What should replace QUESTION in the code below?

f(::Type{QUESTION}) = true
f(Tuple{Int,Int})               # true
f(Tuple{Float64,Vararg{Int}})   # should throw MethodError

Maybe f(::Type{NTuple{N,T}}) where {N,T} = true?

1 Like

Thanks! This works very nicely as a type alias:

const TypeFixargTuple = Type{NTuple{N,T}} where {N,T}
f(::TypeFixargTuple) = true
f(::Any) = false

f(Tuple{Int,Int})               # true
f(Tuple{Vararg{Int}})           # false

Spoke too soon, the above fails with heterogeneous tuples. But the following works:

f(::Type{<:NTuple{N,Any}}) where N = true

f(Tuple{Int,Int})                # true
f(Tuple{Int,Char})               # true