Questions tagged [scalaz-stream]

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.

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.
83 questions
1
vote
1 answer

scalaz-stream tcp `echo` app not work

I write an echo app that send and receive '\0' terminated string https://gist.github.com/jilen/10a664cd588af10b7d09 object Foo { implicit val S = scalaz.concurrent.Strategy.DefaultStrategy implicit val AG =…
jilen
  • 5,633
  • 3
  • 35
  • 84
1
vote
1 answer

In scalaz-stream, how can i run a task when a Sink is terminated?

I have copied an example from http4s: // Print received Text frames, and, on completion, notify the console val sink: Sink[Task, WebSocketFrame] = Process.constant { case Text(t) => Task.delay(println(t)) case f =>…
Atle
  • 428
  • 3
  • 11
1
vote
1 answer

In scalaz stream, how can i turn a Process[Task,Seq] into a Process1[Task,B]

I have a Process[Task,A]. A contains a Seq of Bs case class A(elems:Seq[B]) I would like to transform the Process[Task,A] into a Process[Task,B] def streamOfAs:Process[Task,A] = ??? streamOfBs1:Process[Task,Member] =…
Atle
  • 428
  • 3
  • 11
1
vote
1 answer

How to create a stream with Scalaz-Stream?

It must be damn simple. But for some reason I cannot make it work. If I do io.linesR(...), I have a stream of lines of the file, it's ok. If I do Processor.emitAll(), I have a stream of pre-defined values. It also works. But what I actually need…
Dmitry Kurinskiy
  • 533
  • 1
  • 3
  • 16
1
vote
1 answer

append method from scalaz stream io cause infinite loop

I use this code from scalaz stream website, it is working with to method, but it failed when I try to use append, it looks like into an infinite loop and never finish. The reason I want to use append method is that I dont want to rewrite the file by…
Xiaohe Dong
  • 4,953
  • 6
  • 24
  • 53
1
vote
0 answers

scalaz stream iterate each line and map it to a view object for a large file and return an iterator

I have a very large file and each line can be parsed into a view object. However, I want to return a iterator[A] instead of collection, so it can have better memory characteristics for the large file parsing. factory.createContainer(line: String):…
Xiaohe Dong
  • 4,953
  • 6
  • 24
  • 53
1
vote
1 answer

Why Process0 is not defined as Process[Id, O]

sealed trait Process[+F[_], +O] /** * Created by pach on 11/07/14. */ package object stream { type Process0[+O] = Process[Nothing,O] ... } This is how Process0 defined. Actually I cannot understand why this compiles, because Nothing takes no…
jilen
  • 5,633
  • 3
  • 35
  • 84
1
vote
1 answer

Using scalaz-stream as a real time Writer for asynchronous computations

I have a web-app that does a bunch of slow concurrent work to calculate its result. Instead of leaving the end user hanging I'd like to stream back progress updates via a websocket. My codebase is built up of composition of Scalaz eithers (/)…
Salanki
  • 11
  • 1
1
vote
1 answer

Processing multiple files in parallel with scalaz streams

I'm trying to use scalaz-stream to process multiple files simultaneously, applying a single function to each line in the files, across all the files. For concreteness, suppose I have a function that takes a list of strings def f(lines:…
ncreep
  • 473
  • 3
  • 11
0
votes
2 answers

Scala ZIO Stream -- Convert Stream[A] to Stream[B] where one A produces zero or more B

I have a Stream[A] and a function zeroOrMoreB(value: A): Seq[B] which given an A returns zero or more B. From these two pieces, how to I construct a Stream[B]? I can get a Stream[Stream[B]] (see below), but I cannot figure out how to flatten…
RandomBits
  • 4,194
  • 1
  • 17
  • 30
0
votes
1 answer

Ideal chunk in scala fs2 stream performance gain in production

was wondering if the increase in chunk size in scala fs2 stream will give the performance gain? import cats.effect.{IO, Sync} import fs2.{io, text} import java.nio.file.Paths def fahrenheitToCelsius(f: Double): Double = (f - 32.0) *…
vkt
  • 1,401
  • 2
  • 20
  • 46
0
votes
1 answer

FS2 Running streams in sequence

I have a fairly simple use case. I have two web service calls one fetches products and another fetches relationship. I want to run fetchProducts() first extract a field from the set of products and then pass the output to fetchRelationships(ids:…
0
votes
1 answer

Creating a process from a queue in scalaz

I am trying to follow the first example at https://github.com/functional-streams-for-scala/fs2/wiki/Binding-to-asynchronous-processes Filling in some gaps and adding some debug prints I got to the following code: import…
Peter Zeller
  • 2,245
  • 19
  • 23
0
votes
1 answer

Scala fs2 Streams with Chunks and Tasks?

// Simulated external API that synchronously returns elements one at a time indefinitely. def externalApiGet[A](): A = ??? // This wraps with the proper fs2 stream that will indefinitely return values. def wrapGetWithFS2[A](): Stream[Task,…
clay
  • 18,138
  • 28
  • 107
  • 192
0
votes
1 answer

Scalaz-stream bracket closes a resource early

Consider this code: import java.time.Instant import scalaz.concurrent.Task import scalaz.stream._ class MyResource { println("resource obtained") @volatile var v = 1 def read() = v def close() { v = 0 …
Jan
  • 331
  • 1
  • 12