Skip to content

Instantly share code, notes, and snippets.

@fthomas
Created July 16, 2014 14:45
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 fthomas/9ab18fc9e0aadc534dd4 to your computer and use it in GitHub Desktop.
Save fthomas/9ab18fc9e0aadc534dd4 to your computer and use it in GitHub Desktop.
package scalaz.stream.examples
import scala.util.Random
import scalaz.concurrent.Task
import scalaz.stream._
object Manifesto extends App {
val reactivemanifestowords = "Application requirements have changed dramatically in recent years. Only a few years ago a large application had tens of servers, seconds of response time, hours of offline maintenance and gigabytes of data. Today applications are deployed on everything from mobile devices to cloud-based clusters running thousands of multicore processors. Users expect millisecond or even microsecond response times and 100% uptime. Data needs are expanding into the petabytes.".split(" ").toIndexedSeq
val randomWord: Process[Task, String] =
Process.repeatEval(Task.delay(Random.shuffle(reactivemanifestowords).head))
val aggregateWords: Process1[String, String] =
process1.chunk(2).map(_.mkString(" "))
val process = randomWord.pipe(aggregateWords).through(io.stdOutLines)
process.run.run
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment