provide and document string lenses

This commit is contained in:
AlexKnauth 2015-07-17 18:13:28 -04:00
parent bc08f347f7
commit 3c2db6c1a9
3 changed files with 26 additions and 0 deletions

View File

@ -4,6 +4,7 @@
"join.rkt"
"list.rkt"
"hash.rkt"
"string.rkt"
"view-set.rkt"
"sublist.rkt"
"struct.rkt"
@ -15,6 +16,7 @@
"join.rkt"
"list.rkt"
"hash.rkt"
"string.rkt"
"view-set.rkt"
"sublist.rkt"
"struct.rkt"

View File

@ -13,6 +13,7 @@ this library being backwards-compatible.
@include-section["join.scrbl"]
@include-section["list.scrbl"]
@include-section["hash.scrbl"]
@include-section["string.scrbl"]
@include-section["syntax.scrbl"]
@include-section["sublist.scrbl"]
@include-section["struct.scrbl"]

View File

@ -0,0 +1,23 @@
#lang scribble/manual
@(require lens/doc-util/main)
@title{String Lenses}
@defproc[(string-ref-lens [i exact-nonnegative-integer?]) lens?]{
Returns a lens for viewing the @racket[i]th character of a string.
@lenses-unstable-examples[
(lens-view (string-ref-lens 2) "abcdef")
(lens-set (string-ref-lens 2) "abcdef" #\C)
]}
@defproc[(string-pluck-lens [i exact-nonnegative-integer?]) lens?]{
Like @racket[list-refs-lens], but for strings.
Equivalent to @racket[(lens-join/string (string-ref-lens i) ...)].
@lenses-unstable-examples[
(define 1-5-6-lens (string-pluck-lens 1 5 6))
(check-equal? (lens-view 1-5-6-lens "abcdefg")
"bfg")
(check-equal? (lens-set 1-5-6-lens "abcdefg" "BFG")
"aBcdeFG")
]}