Skip to content

Instantly share code, notes, and snippets.

@zainab-ali
Created October 15, 2024 15:00
Show Gist options
  • Save zainab-ali/ad6983525cd35bc500f472aad25bac43 to your computer and use it in GitHub Desktop.
Save zainab-ali/ad6983525cd35bc500f472aad25bac43 to your computer and use it in GitHub Desktop.
Aquascape describing `evalTap` followed by `parEvalMapUnordered`.
//> using scala "3.5.0"
//> using dep "com.github.zainab-ali::aquascape::0.3.0"
import fs2.*
import cats.effect.*
import aquascape.*
import cats.syntax.all.*
import scala.concurrent.duration.*
object App extends AquascapeApp {
def name: String = "aquascape"
def process(c: Char): IO[Unit] = IO.sleep(1.second)
override def chunked: Boolean = true
def stream(using Scape[IO]) = {
Stream('a', 'b', 'c')
.covary[IO]
.stage("Stream('a','b','c')", "upstream")
.evalTap(process)
.stage("evalTap(process)", "upstream")
.fork("root", "upstream")
.parEvalMapUnordered(3)(c => c.pure[IO].trace())
.stage("parEvalMapUnordered(3)(…)")
.compile
.drain
.compileStage("compile.drain")
}
}
@zainab-ali
Copy link
Author

aquascape

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment