Use define-syntax-parser in auto-hash-ref/explicit.
This commit is contained in:
parent
b07cda477f
commit
5aa816507d
1 changed files with 6 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
#lang typed/racket
|
#lang typed/racket
|
||||||
|
|
||||||
(require typed/graph typed-compose typed/racket/stream
|
(require typed/graph typed-compose typed/racket/stream syntax/parse/define
|
||||||
(for-syntax syntax/parse racket/list))
|
(for-syntax syntax/parse racket/list))
|
||||||
|
|
||||||
(provide
|
(provide
|
||||||
|
@ -45,12 +45,11 @@
|
||||||
(check-equal? (eval1-with ht expr)
|
(check-equal? (eval1-with ht expr)
|
||||||
4)))
|
4)))
|
||||||
|
|
||||||
(define-syntax (auto-hash-ref/explicit stx)
|
(define-syntax-parser auto-hash-ref/explicit
|
||||||
(syntax-parse stx
|
|
||||||
[(_ (ht:id keys:id ...) body:expr)
|
[(_ (ht:id keys:id ...) body:expr)
|
||||||
#`(let #,(for/list ([key (syntax->list #'(keys ...))])
|
#`(let #,(for/list ([key (syntax->list #'(keys ...))])
|
||||||
`[,key (hash-ref ,#'ht ',key)])
|
`[,key (hash-ref ,#'ht ',key)])
|
||||||
body)]))
|
body)])
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(test-case "auto-hash-ref/explicit"
|
(test-case "auto-hash-ref/explicit"
|
||||||
|
|
Loading…
Reference in a new issue