(let ((str (read-file "/tmp/test-output.txt")))
(test str output)))
+(test (data-tors '(A . ((foo Int Bool)
+ (bar Bool))))
+ '((foo . (constructor . (abs Int (abs Bool A))))
+ (foo~0 . (0 . (abs A Int)))
+ (foo~1 . (1 . (abs A Bool)))
+ (bar . (constructor . (abs Bool A)))
+ (bar~0 . (0 . (
+
+ abs A Bool)))))
+
+(test (data-tors-env
+ '(A . ((foo Int Bool)
+ (bar Bool))))
+ '((foo . (abs Int (abs Bool A)))
+ (foo~0 . (abs A Int))
+ (foo~1 . (abs A Bool))
+ (bar . (abs Bool A))
+ (bar~0 . (abs A Bool))))
+
(test-types (typecheck '((lambda (x) (+ ((lambda (y) (x y 3)) 5) 2))))
'(abs (abs Int (abs Int Int)) Int))
(pow 4 2))))
'Int)
+ ; ADTs
+
+
(test-types
(typecheck
'((data A
y)))
'Int)
+
+ ; pattern matching
+(test (let-bindings '(let ([(foo x) a]) x))
+ '((x (foo~0 a))))
+
+(test (let-bindings '(let ([x (foo 42)] [(foo y) x]) x))
+ '((x (foo 42))
+ (y (foo~0 x))))
+
+ ; type annotations
+
+(test (annotate-types
+ '((let ([x 42]
+ [y (+ 1 x)])
+ (- y x))))
+
+ '((let ()
+ ((let ((x (42 : Int))
+ (y (((+ : (abs Int (abs Int Int))) (1 : Int) (x : Int)) : Int)))
+ (((- : (abs Int (abs Int Int))) (y : Int) (x : Int)) : Int)) : Int)) : Int))
+
(test-expr '(+ 1 2) 3)
(test-expr '(bool->int (= 2 0)) 0)
(test-expr '((lambda (x) ((lambda (y) (+ x y)) 42)) 100) 142)
(go p 1)))])
(pow 4 2))
16)
+
+ ; mutual recursion
+;; (test-prog-stdout '((let ([f (lambda (n)
+;; (if (= n 0)
+;; 0
+;; (let ()
+;; (print "a")
+;; (g (- n 1)))))]
+;; [g (lambda (m)
+;; (let ()
+;; (print "b")
+;; (f (- m 1))))])
+;; (f 10))) "ababababab")
+
+ ; adts and pattern matching
+
+(test-prog '((data A [foo Int])
+ (let ([(foo x) (foo 42)])
+ x))
+ 42)