@@ -311,7 +311,7 @@ object Test {
311
311
mapRaw[(B , A ), (A , B )]((t => k => ' { ~ k((t._2, t._1)) }), pushLinear[B , _, A ](producer2, producer1, nestf1))
312
312
313
313
case (Nested (producer1, nestf1), Nested (producer2, nestf2)) =>
314
- zipRaw(makeLinear(stream1), stream2)
314
+ zipRaw(Linear ( makeLinear(stream1) ), stream2)
315
315
}
316
316
}
317
317
@@ -321,10 +321,12 @@ object Test {
321
321
* @tparam A
322
322
* @return
323
323
*/
324
- private def makeLinear [A : Type ](stream : StagedStream [A ]): StagedStream [A ] = {
324
+ private def makeLinear [A : Type ](stream : StagedStream [A ]): Producer [A ] = {
325
325
stream match {
326
- case Linear (producer) => stream
327
- case Nested (producer, nestedf) => {
326
+ case Linear (producer) => producer
327
+ case nested : Nested [A , bt] => {
328
+ val producer : Producer [bt] = nested.producer
329
+ val nestedf : bt => StagedStream [A ] = nested.nestedf
328
330
329
331
/** Helper function that orchestrates the handling of the function that represents an `advance: Unit => Unit`.
330
332
* It reifies a nested stream as calls to `advance`. Advance encodes the step function of each nested stream.
@@ -368,40 +370,39 @@ object Test {
368
370
}
369
371
}
370
372
371
- val newProducer = new Producer [A ] {
373
+ new Producer [A ] {
372
374
// _1: if the stream has ended,
373
375
// _2: the current element,
374
376
// _3: the step of the inner most steam
375
377
type St = (Var [Boolean ], Var [A ], Var [Unit => Unit ])
376
378
val card : Cardinality = Many
377
379
378
380
def init (k : St => Expr [Unit ]): Expr [Unit ] = {
379
- producer.init(st => ' {
381
+ producer.init(st =>
380
382
Var (' { (_ : Unit ) => ()}){ advf => {
381
383
Var (' { true }) { hasNext => {
382
- // Var('{ null.asInstanceOf[A] }) { curr => {
383
- // def adv() = {
384
- // ~hasNext.update(producer.hasNext(st))
385
- // if(~hasNext.get) {
386
- // ~producer.step(st, el => '{
387
- // ~makeAdvanceFunction(advf, ((a: A) => curr.update('{a})), nestedf(el))
388
- // })
389
- // }
390
- // }
391
- // ~k((flag, current, advf))
392
- ???
393
- // }}
384
+ Var (' { null .asInstanceOf [A ] }) { curr => ' {
385
+
386
+ // val adv: Unit => Unit = {
387
+ // ~hasNext.update(producer.hasNext(st))
388
+ // if(~hasNext.get) {
389
+ // ~producer.step(st, (el: bt) => makeAdvanceFunction[Expr[A]](advf, (a => curr.update(a)), nestedf(el)))
390
+ // }
391
+ // }
392
+
393
+ // ~advf.update('{adv})
394
+ // adv(_)
395
+
396
+ ~ k((hasNext, curr, advf))
397
+ }}
394
398
}}
395
- }}
396
- })
399
+ }})
397
400
}
398
401
399
402
def step (st : St , k : A => Expr [Unit ]): Expr [Unit ] = ???
400
403
401
404
def hasNext (st : St ): Expr [Boolean ] = ???
402
405
}
403
-
404
- Linear (newProducer)
405
406
}
406
407
}
407
408
}
0 commit comments