Skip to content

Commit

Permalink
Rename Stream#repeatElems to Stream#spaced
Browse files Browse the repository at this point in the history
  • Loading branch information
iravid committed May 26, 2019
1 parent 67fdc29 commit 986f2a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions streams/jvm/src/test/scala/scalaz/zio/stream/StreamSpec.scala
Expand Up @@ -32,9 +32,9 @@ class StreamSpec(implicit ee: org.specs2.concurrent.ExecutionEnv)
repeat $repeat
short circuits $repeatShortCircuits
Stream.repeatElems
repeatElems $repeatElems
short circuits $repeatElemsShortCircuits
Stream.spaced
spaced $spaced
short circuits $spacedShortCircuits

Stream.take
take $take
Expand Down Expand Up @@ -619,18 +619,18 @@ class StreamSpec(implicit ee: org.specs2.concurrent.ExecutionEnv)
} yield result must_=== List(1, 1)
)

private def repeatElems =
private def spaced =
unsafeRun(
Stream(1, 2, 3)
.repeatElems(Schedule.recurs(1))
.spaced(Schedule.recurs(1))
.run(Sink.collect[Int])
.map(_ must_=== List(1, 1, 2, 2, 3, 3))
)

private def repeatElemsShortCircuits =
private def spacedShortCircuits =
unsafeRun(
Stream(1, 2, 3)
.repeatElems(Schedule.recurs(1))
.spaced(Schedule.recurs(1))
.take(3)
.run(Sink.collect[Int])
.map(_ must_=== List(1, 1, 2))
Expand Down
6 changes: 3 additions & 3 deletions streams/shared/src/main/scala/scalaz/stream/ZStream.scala
Expand Up @@ -396,7 +396,7 @@ trait ZStream[-R, +E, +A] extends Serializable { self =>
self.fold[R2, E1, A1, S].flatMap { f0 =>
f0(s, cont, f).zip(schedule.update((), sched)).flatMap {
case (s, decision) =>
if (decision.cont && cont(s)) IO.unit.delay(decision.delay) *> loop(s, decision.state)
if (decision.cont && cont(s)) loop(s, decision.state).delay(decision.delay)
else IO.succeed(s)
}
}
Expand All @@ -408,7 +408,7 @@ trait ZStream[-R, +E, +A] extends Serializable { self =>
/**
* Repeats elements of the stream using the provided schedule.
*/
def repeatElems[R1 <: R, B](schedule: ZSchedule[R1, A, B]): ZStream[R1 with Clock, E, A] =
def spaced[R1 <: R, B](schedule: ZSchedule[R1, A, B]): ZStream[R1 with Clock, E, A] =
new ZStream[R1 with Clock, E, A] {
override def fold[R2 <: R1 with Clock, E1 >: E, A1 >: A, S]: Fold[R2, E1, A1, S] =
IO.succeedLazy { (s, cont, f) =>
Expand All @@ -418,7 +418,7 @@ trait ZStream[-R, +E, +A] extends Serializable { self =>
f(s, a).zip(schedule.update(a, sched)).flatMap {
case (s, decision) =>
if (decision.cont && cont(s))
IO.unit.delay(decision.delay) *> loop(s, decision.state, a)
loop(s, decision.state, a).delay(decision.delay)
else IO.succeed(s)
}

Expand Down

0 comments on commit 986f2a7

Please sign in to comment.