;; takes a gpolytype (i.e. <!head,xlist*> )
;; and tries to expand on all !bang types ...
;; in other words try to change
;; this <!head,xlist*> into <i64,xlist*>
;; return #f or an expanded
(define impc:ti:reify-generic-type-expand
(lambda (type gnum spec vars)
;; (println 'reifyin: type 'gnum: gnum 'spec: spec) ; 'vars: vars)
(for-each (lambda (v)
;; (println 'v: v)
(if (and (impc:ti:bang-type? (car v))
(if (not gnum) #t
(regex:match? (symbol->string (car v)) (string-append "##" gnum)))
(regex:match? type (car (regex:split (symbol->string (car v)) "(##)|(%)")))
(not (null? (cdr v))))
(let* ((t (impc:ti:type-normalize (impc:ti:type-unify (cdr v) vars)))
;; (llllll (println 't: t))
(tl (if (impc:ir:type? t)
(impc:ir:pretty-print-type t)
'())))
;; (println 'v: v 't: t 'tl: tl)
(if (not (null? tl))
(let* ((xx (car (regex:type-split (symbol->string (car v)) "##")))
(base (impc:ir:get-base-type xx))
(xxx (string-append base "[*]*")))
(set! type (regex:replace-all type xxx tl)))))
#f))
vars)
;; (println 'reifyout: type 'gnum: gnum)
type))