stream-stream-core.nix
Source: /nix/store/mls72plk3raskl1r5afh3cl9ik3rn969-source/nix/stream-core.nix
Module Description
Stream constructors - building streams from values and lists
Combinators
done
Creates a terminated (empty) stream.
Represents the end of a stream - no more elements to produce. This is the base case for stream recursion.
Type Signature
Fx<{}, Step<{}, V>>
Example
eval done.value # => { more = false; }
See Also
more- Continue stream with valuefromList- Create from list (empty list -> done)
fromList
Converts a list to a stream.
Creates a stream that yields each list element in order. Empty list produces a terminated stream.
Type Signature
[V] -> Stream<{}, V>
Parameters
list: List to convert
Example
runFx (toList (fromList [1 2 3])) # => [1 2 3]
runFx (fromList []) # => { more = false; }
See Also
toList- Convert stream to listsingleton- Single element stream
more
Creates a stream step with value and continuation.
Produces a stream that yields one value and continues with the next stream. The continuation is not evaluated until needed, enabling lazy, infinite streams.
Type Signature
V -> Stream<S, V> -> Fx<{}, Step<S, V>>
Parameters
value: Value to yieldnext: Continuation stream (lazy)
Example
more 1 (more 2 (more 3 done))
# Stream of [1, 2, 3]
See Also
done- Terminate streamfromList- Build from list
repeat
Repeats an effect n times as a stream.
Creates a stream that executes the same effect n times, yielding each result. Useful for effectful generation.
Type Signature
Int -> Fx<S, V> -> Stream<S, V>
Parameters
n: Number of times to repeateffect: Effect to execute
Example
runFx (provide 5 (
toList (repeat 3 state.get)
)) # => [5 5 5]
See Also
forEach- Execute for each elementmap- Transform elements
singleton
Creates a single-element stream.
Type Signature
V -> Stream<{}, V>
Parameters
value: Single value to yield
Example
runFx (toList (singleton 42)) # => [42]
See Also
fromList- Multiple elementsdone- No elements
Generated from /nix/store/mls72plk3raskl1r5afh3cl9ik3rn969-source/nix/stream-core.nix