abstract type TypedFun end
abstract type ReturnFun{R} <: TypedFun end
abstract type NoArgFun{R} <: ReturnFun{R} end
abstract type FullFun{Tuple,R} <: ReturnFun{R} end
#single argument function
struct SAFun{T,R} <: FullFun{Tuple{T},R}
fn::Function
end
(⇒)(::Type{T}, ::Type{R}) where {T,R} = SAFun{T, R}
(⇒)(::Nothing, ::Type{R}) where {R} = NoArgFun{R}
struct MM{T}
x::T
end
f(fun::(Any ⇒ MM{T})) where T = fun(3)
the function f definition gives the following error
This works f(fun::(Any ⇒ MM{T} where T)) = fun(3). Note though that the Any ⇒ MM{T} where T part is evaluated at function definition and not later. Thus having the where outside does not make sense.