Chapter 3

Flow and Streams

Understand pipe injection, lazy streams, and single-consumption semantics.

The pipe is the language

The expression lhs |> f(a) injects lhs as the first argument to f. The standard library consistently follows Source → Transform → Filter → Action.

example.hhy
[1, 2, 3, 4, 5]
    |> stream
    |> map { number -> number * 2 }
    |> where { number -> number > 5 }
    |> take(2)
    |> print

Lazy execution

  • Streams pull values on demand instead of materializing all input.
  • A Stream can be consumed only once.
  • take safely bounds finite and infinite streams.
  • Barriers such as sort, group_by, and collect materialize input under resource limits.