scalaz-stream


License

License

MIT
Categories

Categories

Scala Languages
GroupId

GroupId

org.scalaz.stream
ArtifactId

ArtifactId

scalaz-stream_2.10
Last Version

Last Version

0.8.6a
Release Date

Release Date

Type

Type

jar
Description

Description

scalaz-stream
scalaz-stream
Project URL

Project URL

https://github.com/scalaz/scalaz-stream
Project Organization

Project Organization

org.scalaz.stream
Source Code Management

Source Code Management

https://github.com/scalaz/scalaz-stream

Download scalaz-stream_2.10

How to add to project

<!-- https://jarcasting.com/artifacts/org.scalaz.stream/scalaz-stream_2.10/ -->
<dependency>
    <groupId>org.scalaz.stream</groupId>
    <artifactId>scalaz-stream_2.10</artifactId>
    <version>0.8.6a</version>
</dependency>
// https://jarcasting.com/artifacts/org.scalaz.stream/scalaz-stream_2.10/
implementation 'org.scalaz.stream:scalaz-stream_2.10:0.8.6a'
// https://jarcasting.com/artifacts/org.scalaz.stream/scalaz-stream_2.10/
implementation ("org.scalaz.stream:scalaz-stream_2.10:0.8.6a")
'org.scalaz.stream:scalaz-stream_2.10:jar:0.8.6a'
<dependency org="org.scalaz.stream" name="scalaz-stream_2.10" rev="0.8.6a">
  <artifact name="scalaz-stream_2.10" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.scalaz.stream', module='scalaz-stream_2.10', version='0.8.6a')
)
libraryDependencies += "org.scalaz.stream" % "scalaz-stream_2.10" % "0.8.6a"
[org.scalaz.stream/scalaz-stream_2.10 "0.8.6a"]

Dependencies

compile (4)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.10.6
org.scalaz : scalaz-core_2.10 jar 7.2.7
org.scalaz : scalaz-concurrent_2.10 jar 7.2.7
org.scodec : scodec-bits_2.10 jar 1.1.2

test (2)

Group / Artifact Type Version
org.scalaz : scalaz-scalacheck-binding_2.10 jar 7.2.7
org.scalacheck : scalacheck_2.10 jar 1.12.6

Project Modules

There are no modules declared in this project.

scalaz-stream

Build Status Gitter Chat

Where to get it

To get the latest version of the library, add the following to your SBT build:

// available for Scala 2.10.6, 2.11.8, 2.12.0-RC2
libraryDependencies += "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.

About the library

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:

import scalaz.stream._
import scalaz.concurrent.Task

val converter: Task[Unit] =
  io.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

// at the end of the universe...
val 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:

  • Zipping and merging of streams: A streaming computations may read from multiple sources in a streaming fashion, zipping or merging their elements using a arbitrary 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.
  • Dynamic resource allocation: A streaming computation may allocate resources dynamically (for instance, reading a list of files to process from a stream built off a network socket), and the library will ensure these resources get released in the event of normal termination or when errors occur.
  • Nondeterministic and concurrent processing: A computation may read from multiple input streams simultaneously, using whichever result comes back first, and a pipeline of transformation can allow for nondeterminism and queueing at each stage.
  • Streaming parsing (UPCOMING): A separate layer handles constructing streaming parsers, for instance, for streaming JSON, XML, or binary parsing. See the roadmap for more information on this and other upcoming work.

Documentation and getting help

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.

Projects using scalaz-stream

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.

  • http4s: Minimal, idiomatic Scala interface for HTTP services using scalaz-stream
  • scodec-stream: A library for streaming binary decoding and encoding, built using scalaz-stream and scodec
  • streamz: A library that allows a 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.

Related projects

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.

org.scalaz.stream

Scalaz

Versions

Version
0.8.6a
0.8.6
0.8.5a
0.8.5
0.8.4a
0.8.4
0.8.3a
0.8.3
0.8.2a
0.8.2
0.8.1a
0.8.1
0.8a
0.8
0.7.3a
0.7.3
0.7.2a
0.7.2
0.1
snapshot-0.7a