{"size": 1286, "ext": "scrbl", "max_stars_repo_path": "lens-doc/unstable/lens/hash-filterer.scrbl", "max_stars_repo_name": "AlexKnauth/lens", "max_stars_repo_stars_event_min_datetime": "2015-07-08T12:56:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T21:21:54.000Z", "max_issues_repo_path": "lens-doc/unstable/lens/hash-filterer.scrbl", "max_issues_repo_name": "AlexKnauth/lens", "max_issues_repo_issues_event_min_datetime": "2015-07-07T01:47:59.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-10T18:35:17.000Z", "max_forks_repo_path": "lens-doc/unstable/lens/hash-filterer.scrbl", "max_forks_repo_name": "AlexKnauth/lens", "max_forks_repo_forks_event_min_datetime": "2015-07-07T05:01:29.000Z", "max_forks_repo_forks_event_max_datetime": "2019-07-16T00:37:04.000Z"}
{"max_stars_count": 66, "max_issues_count": 199, "max_forks_count": 11, "avg_line_length": 38.9696969697, "max_line_length": 85, "alphanum_fraction": 0.6687402799}
#lang scribble/manual

@(require lens/private/doc-util/main)

@title{Filtering hash-tables}

@defproc[(hash-filterer-lens/key [keep? (-> any/c boolean?)])
         (lens/c immutable-hash? immutable?)]{
Creates a lens that filters a hash-table to keys that pass the predicate
@racket[keep?].
@lens-unstable-examples[
  (lens-view (hash-filterer-lens/key symbol?) (hash 'a 1 "b" 2 'c 3))
  (lens-set (hash-filterer-lens/key symbol?) (hash 'a 1 "b" 2 'c 3) (hash 'd 4 'e 5))
]}

@defproc[(hash-filterer-lens/value [keep? (-> any/c boolean?)])
         (lens/c immutable-hash? immutable?)]{
Like @racket[hash-filterer-lens/value], but filters based on values that pass
@racket[keep?], not keys.
@lens-unstable-examples[
  (lens-view (hash-filterer-lens/value number?) (hash 'a 1 'b "two" 'c 3))
  (lens-set (hash-filterer-lens/value number?) (hash 'a 1 'b "two" 'c 3) (hash 'd 4))
]}

@defproc[(hash-filterer-lens [keep? (-> any/c any/c boolean?)])
         (lens/c immutable-hash? immutable?)]{
Creates a lens that filters a hash-table by the predicate @racket[keep?], which
takes the key and the value as its two arguments.
@lens-unstable-examples[
  (lens-view (hash-filterer-lens =) (hash 1 1.0 2 45 3 3))
  (lens-set (hash-filterer-lens =) (hash 1 1.0 2 45 3 3) (hash 4 4.0 5.0 5))
]}
