(define-module (vdc curry tests)
#:use-module (vdc curry)
+ #:use-module (srfi srfi-1)
#:use-module (srfi srfi-64)
#:use-module (srfi srfi-71))
(define-syntax-rule (test-type given expected-bare)
(test-assert (equal-types? given (parse expected-bare))))
+(define (sym-sets symtab alist)
+ (fold (lambda (x prev)
+ ((@@ (vdc curry) sym-set) prev (car x) (cdr x)))
+ symtab alist))
+
(let ((t e (expand '() '(λc x x))))
(test-type t '(1 . 1))
(test-equal '(lambda (x) x) e))
(let ((t e (expand '() '((λc x x) #t))))
(test-type t 0)
(test-equal #t (primitive-eval e)))
-(let ((bindings `((id . ,(parse '(1 . 1)))
- (∘ . ,(parse '((2 . 3) . ((1 . 2) . (1 . 3)))))
- (⊙ . ,(parse '((1 . 2) . ((2 . 3) . (1 . 3)))))
- (map . ,(parse '((0 . 0) . (0 . 0))))
- (+ . ,(parse '(0 . (0 . 0)))))))
+(let ((bindings
+ (sym-sets
+ '()
+ `((id . ,(parse '(1 . 1)))
+ (∘ . ,(parse '((2 . 3) . ((1 . 2) . (1 . 3)))))
+ (⊙ . ,(parse '((1 . 2) . ((2 . 3) . (1 . 3)))))
+ (map . ,(parse '((0 . 0) . (0 . 0))))
+ (+ . ,(parse '(0 . (0 . 0))))))))
(let ((t e (expand bindings '(∘ id id))))
(test-type t '(7 . 7))
(test-equal e '((∘ id) id)))
(let ((t e (expand bindings '(∘ id id #t))))
(test-type t 0)
(test-equal e '(((∘ id) id) #t)))
+ (let ((t e (expand bindings '(λc f (∘ f)))))
+ (test-type t '((2 . 3) . ((1 . 2) . (1 . 3)))))
(let ((t e (expand bindings '(map (+ 1) '(1 2 3)))))
(test-type t 0)
(test-equal e '((map (+ 1)) '(1 2 3))))
(test-type t #f)
(test-equal e '(+ 1 2 3)))
-(let ((bindings `((* . ,(parse '(0 . (0 . 0)))))))
+(let ((bindings
+ (sym-sets
+ '()
+ `((* . ,(parse '(0 . (0 . 0))))))))
;; Typed Scheme can be used by untyped Scheme...
(let ((t e (expand bindings '(+ 1 (* 2 3) 4))))
(test-type t #f)