commit e573a0927c5ce937bdbb9133b7bcb7828576eead parent e0f96296edc3e0071d49743c85b944720837c629 Author: Stephen Chang <stchang@ccs.neu.edu> Date: Tue, 19 Jul 2016 15:40:17 -0400 add stx-append*-lens Diffstat:
| M | turnstile/append-lens.rkt | | | 15 | +++++++++++++-- |
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git 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