commit 7b422d9a389f06b010805fa6f3abc3518ac0fa48 parent 9d33c3a0e8b887342c0d09596867f0ca9e05d8a7 Author: AlexKnauth <alexander@knauth.org> Date: Sat, 18 Jun 2016 10:12:26 -0400 add postfix-in require form Diffstat:
| A | tapl/postfix-in.rkt | | | 36 | ++++++++++++++++++++++++++++++++++++ |
1 file changed, 36 insertions(+), 0 deletions(-)
diff --git a/tapl/postfix-in.rkt b/tapl/postfix-in.rkt @@ -0,0 +1,36 @@ +#lang racket/base + +(provide postfix-in) + +(require racket/require-syntax + racket/require + (for-syntax racket/base + syntax/parse + )) +(module+ test + (require rackunit)) + +(begin-for-syntax + ;; add-postfix : (-> String (-> String String)) + (define ((add-postfix postfix) str) + (string-append str postfix))) + +(define-require-syntax postfix-in + (lambda (stx) + (syntax-parse stx + [(postfix-in post-id:id require-spec) + #:with post-str:str (symbol->string (syntax-e #'post-id)) + #'(filtered-in (add-postfix 'post-str) require-spec)]))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(module+ test + (require (postfix-in - racket/base)) + + (define-binary-check (check-free-id=? actual expected) + (free-identifier=? actual expected)) + + (check-free-id=? #'#%app- #'#%app) + (check-free-id=? #'λ- #'λ) + (check-free-id=? #'define- #'define) + )