Skip to content

Commit bb533de

Browse files
committed
Fix types for zip
1 parent f54dbfd commit bb533de

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -298,20 +298,20 @@ object Test {
298298
/** A stream containing the first `n` elements of this stream. */
299299
def take(n: Expr[Int]): Stream[A] = Stream(takeRaw[Expr[A]](n, stream))
300300

301-
private def zipRaw[A: Type, B: Type](stream1: StagedStream[A], stream2: StagedStream[B]): StagedStream[(A, B)] = {
301+
private def zipRaw[A: Type, B: Type](stream1: StagedStream[Expr[A]], stream2: StagedStream[B]): StagedStream[(Expr[A], B)] = {
302302
(stream1, stream2) match {
303303

304304
case (Linear(producer1), Linear(producer2)) =>
305305
Linear(zip_producer(producer1, producer2))
306306

307307
case (Linear(producer1), Nested(producer2, nestf2)) =>
308-
pushLinear[A, _, B](producer1, producer2, nestf2)
308+
pushLinear[Expr[A], _, B](producer1, producer2, nestf2)
309309

310310
case (Nested(producer1, nestf1), Linear(producer2)) =>
311-
mapRaw[(B, A), (A, B)]((t => k => '{ ~k((t._2, t._1)) }), pushLinear[B, _, A](producer2, producer1, nestf1))
311+
mapRaw[(B, Expr[A]), (Expr[A], B)]((t => k => '{ ~k((t._2, t._1)) }), pushLinear[B, _, Expr[A]](producer2, producer1, nestf1))
312312

313313
case (Nested(producer1, nestf1), Nested(producer2, nestf2)) =>
314-
zipRaw(Linear(makeLinear(stream1)), stream2)
314+
zipRaw(Linear(makeLinear[A](stream1)), stream2)
315315
}
316316
}
317317

@@ -321,7 +321,7 @@ object Test {
321321
* @tparam A
322322
* @return
323323
*/
324-
private def makeLinear[A: Type](stream: StagedStream[A]): Producer[A] = {
324+
private def makeLinear[A: Type](stream: StagedStream[Expr[A]]): Producer[Expr[A]] = {
325325
stream match {
326326
case Linear(producer) => producer
327327
case nested: Nested[A, bt] => {
@@ -370,7 +370,7 @@ object Test {
370370
}
371371
}
372372

373-
new Producer[A] {
373+
new Producer[Expr[A]] {
374374
// _1: if the stream has ended,
375375
// _2: the current element,
376376
// _3: the step of the inner most steam
@@ -382,24 +382,23 @@ object Test {
382382
Var('{ (_: Unit) => ()}){ advf => {
383383
Var('{ true }) { hasNext => {
384384
Var('{ null.asInstanceOf[A] }) { curr => '{
385+
val adv: Unit => Unit = { _ =>
386+
~hasNext.update(producer.hasNext(st))
387+
if(~hasNext.get) {
388+
// ~producer.step(st, (el: bt) => makeAdvanceFunction[Expr[A]](advf, (a => curr.update(a)), nestedf(el)))
389+
}
390+
}
385391

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(_)
392+
~advf.update('{adv})
393+
adv(())
395394

396395
~k((hasNext, curr, advf))
397396
}}
398397
}}
399398
}})
400399
}
401400

402-
def step(st: St, k: A => Expr[Unit]): Expr[Unit] = ???
401+
def step(st: St, k: Expr[A] => Expr[Unit]): Expr[Unit] = ???
403402

404403
def hasNext(st: St): Expr[Boolean] = ???
405404
}
@@ -467,7 +466,7 @@ object Test {
467466

468467
val Stream(stream_b) = stream2
469468

470-
Stream(mapRaw[(Expr[A], Expr[B]), Expr[C]]((t => k => '{ ~k(f(t._1)(t._2)) }), zipRaw[Expr[A], Expr[B]](stream, stream_b)))
469+
Stream(mapRaw[(Expr[A], Expr[B]), Expr[C]]((t => k => '{ ~k(f(t._1)(t._2)) }), zipRaw[A, Expr[B]](stream, stream_b)))
471470
}
472471
}
473472

0 commit comments

Comments
 (0)