(define impc:ir:type?
(lambda (type)
(if (string? type)
(if (and (char=? (string-ref type 0) #\%)
(impc:ti:namedtype-exists?
(substring (impc:ir:get-base-type type) 1
(string-length (impc:ir:get-base-type type)))))
#t
(impc:ir:type? (impc:ir:get-type-from-str type)))
(cond ((null? type) #f)
((and (number? type)
;; (or (< type 0) (< (modulo type *impc:ir:pointer*) *impc:ir:closure*)) ;; this should be true but is actually more trouble than it's worth at this stage
(< type 1001))
#t)
((and (list? type)
(number? (car type))
(or (impc:ir:closure? type)
(impc:ir:tuple? type))
(cl:every (lambda (x) x)
(map (lambda (a) (impc:ir:type? a)) (cdr type))))
#t)
((and (list? type)
(number? (car type))
(or (impc:ir:array? type)
(impc:ir:vector? type))
(impc:ir:type? (caddr type)))
#t)
(else #f)))))