Created
October 15, 2024 15:00
-
-
Save zainab-ali/ad6983525cd35bc500f472aad25bac43 to your computer and use it in GitHub Desktop.
Aquascape describing `evalTap` followed by `parEvalMapUnordered`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//> 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") | |
} | |
} |
Author
zainab-ali
commented
Oct 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment