diff options
Diffstat (limited to 'infer2.scm')
-rw-r--r-- | infer2.scm | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -143,13 +143,12 @@ vals*)) (define env* (append (map cons vars val-types) env)) (define body* (annotate-exp body env*)) - (pk 'body* body*) - (make-texp (texp-types body*) + (make-texp (map (lambda (_type) (fresh-type-variable)) (texp-types body*)) `(let ,(map list vars vals*) ,body*))) (define-matcher (annotate:begin ('begin exps ... last) env) (define last* (annotate-exp last env)) - (make-texp (texp-types last*) + (make-texp (map (lambda (_type) (fresh-type-variable)) (texp-types last*)) `(begin ,@(map (lambda (exp) (annotate-exp exp env)) exps) ,last*))) @@ -222,12 +221,15 @@ (define-matcher (constrain:let ((? type? types) ...) ('let (((? symbol? vars) (? texp? vals)) ...) (? texp? body))) - (append (program-constraints body) - (append-map program-constraints vals))) + (cons (constrain types (texp-types body)) + (append (program-constraints body) + (append-map program-constraints vals)))) (define-matcher (constrain:begin ((? type? types) ...) - ('begin (? texp? texps) ...)) - (append-map program-constraints texps)) + ('begin (? texp? texps) ... (? texp? last))) + (cons (constrain types (texp-types last)) + (append (program-constraints last) + (append-map program-constraints texps)))) (define-matcher (constrain:lambda ((? procedure-type? type)) ('lambda ((? symbol? args) ...) |