Skip to content

Instantly share code, notes, and snippets.

@zainab-ali
Last active October 15, 2024 15:19
Show Gist options
  • Save zainab-ali/84ba2f82480ea3e95d059fd92cac02f4 to your computer and use it in GitHub Desktop.
Save zainab-ali/84ba2f82480ea3e95d059fd92cac02f4 to your computer and use it in GitHub Desktop.
Aquascape describing `parEvalMapUnordered` and chunk preservation semantics.
//> using dep "com.github.zainab-ali::aquascape::0.3.0"
import fs2.*
import cats.effect.*
import aquascape.*
import cats.syntax.all.*
object App extends AquascapeApp {
def name: String = "aquascape"
override def chunked: Boolean = true
def stream(using Scape[IO]) = {
Stream('a', 'b', 'c')
.covary[IO]
.stage("Stream('a','b','c')", "upstream")
.fork("root", "upstream")
.parEvalMapUnordered(3)(c => c.pure[IO].trace())
.stage("parEvalMapUnordered(3)(…)")
.compile
.drain
.compileStage("compile.drain")
}
}
@zainab-ali
Copy link
Author

Generate a PNG with scala-cli https://gist.github.com/zainab-ali/84ba2f82480ea3e95d059fd92cac02f4.

Alternatively create a JS bundle:

scala-cli --power package --js-version 1.16.0 --js https://gist.github.com/zainab-ali/84ba2f82480ea3e95d059fd92cac02f4

And include it in a webpage:

<html>
  <head>
    <script src="App.js" type="text/javascript"/>
  </head>
  <body>
    <h1>Aquascape playground</h1>
    <p>The aquascape you have compiled to <code>App.js</code> is rendered below:</p>
    <div id="aquascape">
  </body>
</html>

@zainab-ali
Copy link
Author

aquascape

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