(define impc:ir:genericfunc-match-closure-types
(lambda (a b)
(let* ((t1 (if (or (string=? a "_")
(not (char=? (string-ref a 0) #\[)))
'()
(impc:ir:get-pretty-closure-arg-strings a)))
(t2 (if (or (string=? b "_")
(not (char=? (string-ref b 0) #\[)))
'()
(impc:ir:get-pretty-closure-arg-strings b))))
(if (<> (length t1) (length t2))
-1
(let ((weight (apply +
(map (lambda (x y)
(cond ((string=? x "_") 0)
((string=? x y) 1)
((string=? y "_") 0)
(else -1)))
t1 t2))))
;;(println 'a a 'b b 'weight (/ weight (length t1)))
(if (> weight 0) weight ;;(/ weight (length t1))
(if (< weight 0) -1
1/4))))))) ;; give some slight weighting (more than 0) just for being a valid closure