www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

postfix-in.rkt (981B)


      1 #lang racket/base
      2 
      3 (provide postfix-in)
      4 
      5 (require racket/require-syntax
      6          racket/require
      7          (for-syntax racket/base
      8                      syntax/parse
      9                      ))
     10 (module+ test
     11   (require rackunit))
     12 
     13 (begin-for-syntax
     14   ;; add-postfix : (-> String (-> String String))
     15   (define ((add-postfix postfix) str)
     16     (string-append str postfix)))
     17 
     18 (define-require-syntax postfix-in
     19   (lambda (stx)
     20     (syntax-parse stx
     21       [(postfix-in post-id:id require-spec)
     22        #:with post-str:str (symbol->string (syntax-e #'post-id))
     23        #'(filtered-in (add-postfix 'post-str) require-spec)])))
     24 
     25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     26 
     27 (module+ test
     28   (require (postfix-in - racket/base))
     29 
     30   (define-binary-check (check-free-id=? actual expected)
     31     (free-identifier=? actual expected))
     32   
     33   (check-free-id=? #'#%app- #'#%app)
     34   (check-free-id=? #'λ- #'λ)
     35   (check-free-id=? #'define- #'define)
     36   )