Skip to content

Instantly share code, notes, and snippets.

@jonoabroad
Created October 30, 2014 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonoabroad/b8915471b958e4772b4e to your computer and use it in GitHub Desktop.
Save jonoabroad/b8915471b958e4772b4e to your computer and use it in GitHub Desktop.
Non terminating scalaz streams zipwith.
import concurrent.duration._
import scalaz.stream._
import scalaz.concurrent._
import org.joda.time.DateTime
/**
* Requires the following libs :
*
* "org.scalaz.stream" %% "scalaz-stream" % "0.5a",
* "joda-time" % "joda-time" % "2.4"
*
*/
object Noodle extends App {
implicit val mooose = Strategy.DefaultTimeoutScheduler
val input = Process.emitAll(1 to 5)
val pulse = Process.awakeEvery(1.second)
val console: Sink[Task, Int] = Process.constant { case i ⇒ Task.delay(println(s"$i ${DateTime.now()}")) }
val ignorePulse = { (i: Int, _: Duration) ⇒ i }
input.zipWith(pulse)(ignorePulse)
.observe(console)
.run
.run
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment