Use define-syntax-parse-rule in make-tabulate*.

This commit is contained in:
Sergiu Ivanov 2022-03-31 23:45:38 +02:00
parent 5aa816507d
commit 1e4f6d3fbc

View File

@ -11,6 +11,7 @@
(module typed typed/racket
(require "utils.rkt"
syntax/parse/define
(only-in typed/racket/unsafe unsafe-provide)
(for-syntax syntax/parse))
@ -76,13 +77,11 @@
(check-false (g #t #f))
(check-exn exn:fail? (λ () (g #t #f #f))))
(define-syntax (make-tabulate* stx)
(syntax-parse stx
[(_ name:id row-op)
#'(define (name funcs doms)
(for/list ([xs (in-list (apply cartesian-product doms))])
(row-op xs (for/list ([f funcs]) : (Listof b)
(apply f xs)))))]))
(define-syntax-parse-rule (make-tabulate* name:id row-op)
(define (name funcs doms)
(for/list ([xs (in-list (apply cartesian-product doms))])
(row-op xs (for/list ([f funcs]) : (Listof b)
(apply f xs))))))
(: tabulate* (All (b a ... ) (-> (Listof (-> a ... b)) (List (Listof a) ... a)
(Listof (Listof (U Any b))))))