Skip to content

Commit ad2f6c8

Browse files
committed
Add comments
1 parent e2e9484 commit ad2f6c8

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tests/run-with-compiler-custom-args/staged-streams_1.scala

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,35 @@ object Test {
2121
}
2222
}
2323

24+
/*** Producer represents a linear production of values.
25+
*
26+
* Conceptually the design of the producer has its roots in `unfold` where a stream is a product type of some state
27+
* and a stepper function. The latter transforms the state and returns either the end-of-the-stream or a value and
28+
* the new state. The existential quantification over the state keeps it private: the only permissible operation is
29+
* to pass it to the step function.
30+
*
31+
* @tparam A type of the collection elements
32+
*/
2433
trait Producer[A] { self =>
2534
type St
2635
val card: Cardinality
2736

37+
/** Initialization method that defines new state, if needed by the combinator that this producer defines.
38+
*
39+
* e.g., `addCounter` which adds a counter
40+
*
41+
* @param k the continuation that is invoked after the new state is defined in the body of `init`
42+
* @return expr value of unit per the CPS-encoding
43+
*/
2844
def init(k: St => Expr[Unit]): Expr[Unit]
45+
46+
/** Step method that defines the transformation of data, if applicable.
47+
*
48+
*
49+
* @param st
50+
* @param k
51+
* @return
52+
*/
2953
def step(st: St, k: (A => Expr[Unit])): Expr[Unit]
3054
def hasNext(st: St): Expr[Boolean]
3155
}
@@ -183,7 +207,7 @@ object Test {
183207
Stream(flatMapRaw[Expr[A], Expr[A]]((a => { Linear(filterStream(a)) }), stream))
184208
}
185209

186-
/** Adds a new termination condition to a producer of cardinality `Many`.
210+
/** Adds a new termination condition to a stream (recursively if nested) of cardinality `Many`.
187211
*
188212
* @param condition the termination condition as a function accepting the existing condition (the result
189213
* of the `hasNext` from the passed `stream`'s producer.

0 commit comments

Comments
 (0)