Are there macros/traits for inspecting a proc function pointer type?
Examples: 1) Being able to iterate on each argument type
template foo(f: proc(int)) =
for typ in f.argsTypes:
// do something with the type
Macros are capable of getting the arguement/return type. The following code will echo out the following ast.
import macros
macro test(a: typed): untyped =
echo a.getImpl().treeRepr
let a = proc(i: int): float = 1.0
a.test
IdentDefs
Sym "a"
Empty
Lambda
Sym ":anonymous"
Empty
Empty
FormalParams
Sym "float"
IdentDefs
Sym "i"
Sym "int"
Empty
Empty
Empty
Asgn
Sym "result"
FloatLit 1.0
Sym "result"
Which should let you generate all the logic you want to.