(load "ast.scm")
+
+(define (abs? t)
+ (and (list? t) (eq? (car t) 'abs)))
+
+(define (tvar? t)
+ (and (not (list? t)) (not (concrete? t)) (symbol? t)))
+
+(define (concrete? t)
+ (case t
+ ('int #t)
+ ('bool #t)
+ (else #f)))
+
+(define (pretty-type t)
+ (cond ((abs? t)
+ (string-append
+ (if (abs? (cadr t))
+ (string-append "(" (pretty-type (cadr t)) ")")
+ (pretty-type (cadr t)))
+ " -> "
+ (pretty-type (caddr t))))
+ (else (symbol->string t))))
+
; ('a, ('b, 'a))
(define (env-lookup env n)
(if (null? env) (error #f "empty env") ; it's a type equality
res))
(cadr (check '() (normalize prog))))
-
-(define (abs? t)
- (and (list? t) (eq? (car t) 'abs)))
-
-(define (tvar? t)
- (and (not (list? t)) (not (concrete? t)) (symbol? t)))
-
-(define (concrete? t)
- (case t
- ('int #t)
- ('bool #t)
- (else #f)))
-
; returns a list of pairs of constraints
(define (unify a b)
(cond ((eq? a b) '())