Name: scalaz-stream
Owner: Scalaz
Description: Compositional, streaming I/O library for Scala
Forked from: functional-streams-for-scala/fs2
Created: 2016-03-18 00:12:32.0
Updated: 2018-04-11 09:26:17.0
Pushed: 2016-11-16 23:26:26.0
Size: 3398
Language: Scala
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
To get the latest version of the library, add the following to your SBT build:
vailable for Scala 2.10.6, 2.11.8, 2.12.0-RC2
aryDependencies += "org.scalaz.stream" %% "scalaz-stream" % "0.8.5"
As of version 0.8, scalaz-stream is solely published against scalaz 7.1.x. The most recent build for 7.0.x is scalaz-stream 0.7.3.
If you were using a previous version of scalaz-stream, you may have a resolvers
entry for the Scalaz Bintray repository. This is no longer required, as scalaz-stream is now published to Maven Central. It won't hurt you though.
scalaz-stream
is a streaming I/O library. The design goals are compositionality, expressiveness, resource safety, and speed. The design is meant to supersede or replace older iteratee or iteratee-style libraries. Here's a simple example of its use:
rt scalaz.stream._
rt scalaz.concurrent.Task
converter: Task[Unit] =
.linesR("testdata/fahrenheit.txt")
.filter(s => !s.trim.isEmpty && !s.startsWith("//"))
.map(line => fahrenheitToCelsius(line.toDouble).toString)
.intersperse("\n")
.pipe(text.utf8Encode)
.to(io.fileChunkW("testdata/celsius.txt"))
.run
t the end of the universe...
u: Unit = converter.run
This will construct a Task
, converter
, which reads lines incrementally from testdata/fahrenheit.txt
, skipping blanklines and commented lines. It then parses temperatures in degrees fahrenheit, converts these to celsius, UTF-8 encodes the output and writes incrementally to testdata/celsius.txt
, using constant memory. The input and output files will be closed in the event of normal termination or exceptions.
The library supports a number of other interesting use cases:
Tee
. In general, clients have a great deal of flexibility in what sort of topologies they can define–source, sinks, and effectful channels are all first-class concepts in the library.There are examples (with commentary) in the test directory scalaz.stream.examples
. Also see the wiki for more documentation. If you use scalaz.stream
, you're strongly encouraged to submit additional examples and add to the wiki!
For questions about the library, use the scalaz mailing list or the scalaz-stream tag on StackOverflow.
Blog posts and other external resources are listed on the Additional Resources page.
If you have a project you'd like to include in this list, send a message to the scalaz mailing list and we'll add a link to it here.
Process
to consume from and produce to Apache Camel endpoints, Akka Persistence journals and snapshot stores and Akka Stream flows (reactive streams) with full back-pressure support.Machines is a Haskell library with the same basic design as scalaz-stream
, though some of the particulars differ. There is also scala-machines
, which is an older, deprecated version of the basic design of scalaz-stream
.
There are various other iteratee-style libraries for doing compositional, streaming I/O in Scala, notably the scalaz/iteratee
package and iteratees in Play.