document match-lens and provide from unstable/lens
This commit is contained in:
parent
1ec18563fd
commit
f1cd9ff5a5
|
@ -7,6 +7,7 @@
|
|||
"isomorphism.rkt"
|
||||
"mapper.rkt"
|
||||
"string-split.rkt"
|
||||
"match.rkt"
|
||||
)
|
||||
|
||||
(provide (all-from-out "syntax.rkt"
|
||||
|
@ -16,4 +17,5 @@
|
|||
"isomorphism.rkt"
|
||||
"mapper.rkt"
|
||||
"string-split.rkt"
|
||||
"match.rkt"
|
||||
))
|
||||
|
|
|
@ -16,3 +16,4 @@ this library being backwards-compatible.
|
|||
@include-section["isomorphism.scrbl"]
|
||||
@include-section["mapper.scrbl"]
|
||||
@include-section["string-split.scrbl"]
|
||||
@include-section["match.scrbl"]
|
||||
|
|
21
unstable/lens/match.scrbl
Normal file
21
unstable/lens/match.scrbl
Normal file
|
@ -0,0 +1,21 @@
|
|||
#lang scribble/manual
|
||||
|
||||
@(require lens/doc-util/main)
|
||||
|
||||
@title{Lenses based on match patterns}
|
||||
|
||||
@defform[(match-lens id pattern replacement)]{
|
||||
Creates a lens for viewing the @racket[id] within the @racket[pattern].
|
||||
|
||||
The @racket[replacement] expression should be an expression such that
|
||||
@racket[(match target [pattern replacement])] produces a value equivalent to
|
||||
@racket[target], and should use @racket[id] as the view.
|
||||
@lenses-unstable-examples[
|
||||
(define car-lens (match-lens a (cons a b) (cons a b)))
|
||||
(define cdr-lens (match-lens b (cons a b) (cons a b)))
|
||||
(define third-lens (match-lens c (list a b c d ...) (list* a b c d)))
|
||||
(define vector-second-lens (match-lens b (vector a b c ...) (apply vector a b c)))
|
||||
(define v2-of-l3-lens (match-lens d
|
||||
(list a b (vector c d e ...) f ...)
|
||||
(list* a b (apply vector c d e) f)))
|
||||
]}
|
Loading…
Reference in New Issue
Block a user