From e573a0927c5ce937bdbb9133b7bcb7828576eead Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Tue, 19 Jul 2016 15:40:17 -0400 Subject: [PATCH] add stx-append*-lens --- turnstile/append-lens.rkt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/turnstile/append-lens.rkt b/turnstile/append-lens.rkt index 3ffbdde..53340e0 100644 --- a/turnstile/append-lens.rkt +++ b/turnstile/append-lens.rkt @@ -1,8 +1,8 @@ #lang racket/base -(provide append*-lens append*n-lens) +(provide append*-lens append*n-lens stx-append*-lens) -(require lens racket/match racket/list) +(require lens unstable/lens racket/match racket/list syntax/stx) (module+ test (require rackunit syntax/parse lens/private/test-util/test-lens)) @@ -34,6 +34,17 @@ (define (append*n-lens n) (apply lens-thrush (make-list n append*-lens))) +(define stx->lol-lens + (make-lens + (lambda (stx) (stx-map stx->list stx)) + datum->syntax)) ; orig stx is 1st ctx arg +(define l->stx-lens + (make-lens + (lambda (x) x) + (lambda (l stx) (stx->list stx)))) +(define stx-append*-lens + (lens-thrush stx->lol-lens append*-lens l->stx-lens)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (module+ test