From 5aa816507db68086c39a80a4be44b1e78a85427f Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Thu, 31 Mar 2022 23:40:12 +0200 Subject: [PATCH] Use define-syntax-parser in auto-hash-ref/explicit. --- utils.rkt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/utils.rkt b/utils.rkt index c47fadc..0602978 100644 --- a/utils.rkt +++ b/utils.rkt @@ -1,6 +1,6 @@ #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)) (provide @@ -45,12 +45,11 @@ (check-equal? (eval1-with ht expr) 4))) -(define-syntax (auto-hash-ref/explicit stx) - (syntax-parse stx - [(_ (ht:id keys:id ...) body:expr) - #`(let #,(for/list ([key (syntax->list #'(keys ...))]) - `[,key (hash-ref ,#'ht ',key)]) - body)])) +(define-syntax-parser auto-hash-ref/explicit + [(_ (ht:id keys:id ...) body:expr) + #`(let #,(for/list ([key (syntax->list #'(keys ...))]) + `[,key (hash-ref ,#'ht ',key)]) + body)]) (module+ test (test-case "auto-hash-ref/explicit"