Core
Stream primitives: done/more/fromList/iterate/range/replicate.
done
done: terminate a stream with a final value; produces a pure Step tagged Done carrying that value as the stream's result.
done : a -> Computation (Step a b)
Terminate a stream with a final value. Returns a pure Computation
whose _tag is "Done" and whose value is the supplied result.
fromList
fromList: convert a Nix list into a stream; emits each element as More and terminates with Done null.
fromList : [a] -> Computation (Step null a)
Create a stream from a list. The empty list collapses to done null.
iterate
iterate: build an infinite stream by repeated application: [x, f x, f (f x), ...]; must be paired with a limiting combinator to terminate.
iterate : (a -> a) -> a -> Computation (Step r a)
Create an infinite stream by repeated application:
iterate f x = [x, f(x), f(f(x)), ...]
Must be consumed with a limiting combinator (take, takeWhile).
more
more: yield one head element followed by a continuation stream; produces a pure Step tagged More with head and tail fields.
more : a -> Computation (Step r a) -> Computation (Step r a)
Yield an element and a continuation stream. The tail argument is
a Computation, so the rest of the stream stays lazy.
range
range: build a stream of integers from start inclusive to end exclusive; empty when start >= end.
range : Int -> Int -> Computation (Step null Int)
Create a stream of integers from start (inclusive) to end
(exclusive). Empty when start >= end.
replicate
replicate: build a stream of n copies of value x; empty when n <= 0, otherwise emits n More steps then Done null.
replicate : Int -> a -> Computation (Step null a)
Create a stream of n copies of a value. Empty when n <= 0.