How to dispatch on non-vararg Tuple types

question

#1

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

#2

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


#3

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

#4

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