{"size": 944, "ext": "scrbl", "max_stars_repo_path": "lens-doc/lens/private/stream/stream.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/lens/private/stream/stream.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/lens/private/stream/stream.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": 29.5, "max_line_length": 84, "alphanum_fraction": 0.7023305085}
#lang scribble/manual

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


@title[#:tag "streams-reference"]{Stream Lenses}

@defmodule[lens/data/stream]

@see-guide-note["streams-guide"]{stream lenses}

@defthing[stream-first-lens lens?]{
A lens for viewing the first element of a stream.
@lens-examples[
  (lens-view stream-first-lens (stream 1 2 3))
  (stream->list (lens-set stream-first-lens (stream 1 2 3) 'a))
]}

@defthing[stream-rest-lens lens?]{
A lens for viewing the rest of a stream after the first element.
@lens-examples[
  (stream->list (lens-view stream-rest-lens (stream 1 2 3)))
  (stream->list (lens-set stream-rest-lens (stream 1 2 3) (stream 200 300 400 500)))
]}

@defproc[(stream-ref-lens [i exact-nonnegative-integer?]) lens?]{
A lens for viewing the @racket[i]th element of a stream.
@lens-examples[
  (lens-view (stream-ref-lens 2) (stream 1 2 3 4 5 6))
  (stream->list (lens-set (stream-ref-lens 2) (stream 1 2 3 4 5 6) 'a))
]}
