From a2ee741832a98ce3b73066cc188bb2f32f94e25f Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 2 Jun 2014 14:12:20 -0400 Subject: [PATCH] matcher-key-set/single --- minimart/core.rkt | 1 + minimart/route.rkt | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/minimart/core.rkt b/minimart/core.rkt index 3727c01..3c9d3ae 100644 --- a/minimart/core.rkt +++ b/minimart/core.rkt @@ -21,6 +21,7 @@ (struct-out capture) pretty-print-matcher matcher-key-set + matcher-key-set/single projection->pattern sub diff --git a/minimart/route.rkt b/minimart/route.rkt index 117ec44..e557db4 100644 --- a/minimart/route.rkt +++ b/minimart/route.rkt @@ -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)