stream-stream-transform.nix
Source: /nix/store/mls72plk3raskl1r5afh3cl9ik3rn969-source/nix/stream-transform.nix
Module Description
Stream transformation operations - mapping and filtering
Combinators
filter
Keeps only elements matching a predicate.
Lazily filters stream, skipping elements that don’t match. May need to evaluate multiple steps to find next match.
Type Signature
(V -> Bool) -> Stream<S, V> -> Stream<S, V>
Parameters
pred: Predicate functionstream: Source stream
Example
runFx (toList (filter (x: x > 2) (fromList [1 2 3 4])))
# => [3 4]
See Also
takeWhile- Take until predicate failsmap- Transform all elements
map
Transforms each element in a stream.
Applies a pure function to every value in the stream, preserving structure and laziness.
Type Signature
(V -> U) -> Stream<S, V> -> Stream<S, U>
Parameters
f: Transformation functionstream: Source stream
Example
runFx (toList (map (x: x * 2) (fromList [1 2 3])))
# => [2 4 6]
See Also
filter- Select elementsflatMap- Transform and flatten
Generated from /nix/store/mls72plk3raskl1r5afh3cl9ik3rn969-source/nix/stream-transform.nix