@@ -311,7 +311,7 @@ object Test {
311311 mapRaw[(B , A ), (A , B )]((t => k => ' { ~ k((t._2, t._1)) }), pushLinear[B , _, A ](producer2, producer1, nestf1))
312312
313313 case (Nested (producer1, nestf1), Nested (producer2, nestf2)) =>
314- zipRaw(makeLinear(stream1), stream2)
314+ zipRaw(Linear ( makeLinear(stream1) ), stream2)
315315 }
316316 }
317317
@@ -321,10 +321,12 @@ object Test {
321321 * @tparam A
322322 * @return
323323 */
324- private def makeLinear [A : Type ](stream : StagedStream [A ]): StagedStream [A ] = {
324+ private def makeLinear [A : Type ](stream : StagedStream [A ]): Producer [A ] = {
325325 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
328330
329331 /** Helper function that orchestrates the handling of the function that represents an `advance: Unit => Unit`.
330332 * It reifies a nested stream as calls to `advance`. Advance encodes the step function of each nested stream.
@@ -368,40 +370,39 @@ object Test {
368370 }
369371 }
370372
371- val newProducer = new Producer [A ] {
373+ new Producer [A ] {
372374 // _1: if the stream has ended,
373375 // _2: the current element,
374376 // _3: the step of the inner most steam
375377 type St = (Var [Boolean ], Var [A ], Var [Unit => Unit ])
376378 val card : Cardinality = Many
377379
378380 def init (k : St => Expr [Unit ]): Expr [Unit ] = {
379- producer.init(st => ' {
381+ producer.init(st =>
380382 Var (' { (_ : Unit ) => ()}){ advf => {
381383 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+ }}
394398 }}
395- }}
396- })
399+ }})
397400 }
398401
399402 def step (st : St , k : A => Expr [Unit ]): Expr [Unit ] = ???
400403
401404 def hasNext (st : St ): Expr [Boolean ] = ???
402405 }
403-
404- Linear (newProducer)
405406 }
406407 }
407408 }
0 commit comments