(define impc:ti:expand-generic-type-func-gpoly-arity
(lambda (name xvararity)
(let* ((all-gpolys (cl:remove-if-not (lambda (x) (equal? (car x) name)) *impc:ti:genericfunc-cache*))
(all-gtypes (map (lambda (x) (caddr x)) all-gpolys))
(all-type-arity (map (lambda (x) (length
(cl:remove-duplicates
(regex:match-all (symbol->string x)
"(![A-Za-z0-9_]*)"))))
all-gtypes))
(res (cl:remove #f (map (lambda (x y) (if (= x xvararity) y #f)) all-type-arity all-gtypes))))
(if (<> (length res) 1)
(impc:compiler:print-expansion-arity-error name (string->symbol (string-append "no_valid_arity_for_" (atom->string xvararity) "_gvar")))
res))))