(define impc:ir:pretty-print-type
(lambda (t)
(if (null? t)
(impc:compiler:print-compiler-error "impc:ir:pretty-print-type cannot print null type")
(if (string? t)
(if (impc:ti:namedtype-exists? (impc:ir:get-base-type t))
(if (regex:match? t "_poly_")
(let* ((base (impc:ir:get-base-type t))
(ptrs (impc:ir:get-ptr-depth t))
(p (regex:split base "_poly_"))
(typevars (impc:ir:get-generic-tuple-typevars t))
;; (lllllll (println 'typevars typevars))
(res (string-append (substring (car p) 1 (string-length (car p)))
"{"
(string-join (map (lambda (x) (impc:ir:pretty-print-type (cdr x))) typevars) ",")
"}"
(make-string ptrs #\*))))
res)
(if (char=? (string-ref t 0) #\%)
(substring t 1 (string-length t))
t))
(impc:ir:pretty-print-type (impc:ir:get-type-from-pretty-str t)))
(if (or (null? t) (not (impc:ir:type? t))) '()
(cond ((atom? t) (impc:ir:get-type-str t))
((impc:ir:tuple? t)
(string-append "<" (string-join (map (lambda (k) (impc:ir:pretty-print-type k)) (cdr t)) ",")
">" (make-string (impc:ir:get-ptr-depth t) #\*)))
((impc:ir:array? t)
(string-append "|" (number->string (cadr t)) "," (impc:ir:pretty-print-type (caddr t))
"|" (make-string (impc:ir:get-ptr-depth t) #\*)))
((impc:ir:vector? t)
(string-append "/" (number->string (cadr t)) "," (impc:ir:pretty-print-type (caddr t))
"/" (make-string (impc:ir:get-ptr-depth t) #\*)))
((impc:ir:closure? t)
(string-append "[" (string-join (map (lambda (k) (impc:ir:pretty-print-type k)) (cdr t)) ",")
"]" (make-string (- (impc:ir:get-ptr-depth t) 1) #\*)))))))))