Created
October 30, 2014 00:54
-
-
Save jonoabroad/b8915471b958e4772b4e to your computer and use it in GitHub Desktop.
Non terminating scalaz streams zipwith.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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