(define (bind-data-deconstructors n type constructors)
;; (println 'datadecont 'n n 'type type 'constructors constructors)
(map (lambda (x num)
(let ((args (map (lambda (x) (string->symbol (string-append "a" (number->string x)))) (range (length (cdr x)))))
(getter (string->symbol (string-append (symbol->string n) "_get_" (symbol->string (car x))))))
`(bind-func ,(deconstructor-name-and-type n type x)
(lambda (obj success fail)
(if (= (tref obj 0) ,num)
(let ((cir (,getter obj)))
(success ,@(map (lambda (anum) `(tref cir ,anum)) (range (- (length x) 1)))))
(fail))))))
constructors
(range (length constructors))))