matcher-key-set/single

This commit is contained in:
Tony Garnock-Jones 2014-06-02 14:12:20 -04:00
parent 58a0af38a6
commit a2ee741832
2 changed files with 8 additions and 0 deletions

View File

@ -21,6 +21,7 @@
(struct-out capture)
pretty-print-matcher
matcher-key-set
matcher-key-set/single
projection->pattern
sub

View File

@ -28,6 +28,7 @@
projection->pattern
matcher-project
matcher-key-set
matcher-key-set/single
pretty-print-matcher
matcher->jsexpr
jsexpr->matcher
@ -690,6 +691,12 @@
(lambda (m)
(walk-seq m (lambda (vss vsk) vss)))))
;; Matcher → (Option (Setof Value))
;; As matcher-key-set, but extracts just the first captured subvalue.
(define (matcher-key-set/single m)
(define vss (matcher-key-set m))
(and vss (for/set [(vs (in-set vss))] (car vs))))
(define (struct-type-name st)
(define-values (name x2 x3 x4 x5 x6 x7 x8) (struct-type-info st))
name)