This file contains 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 javaOpt -Xmx200m | |
//> using scala "3.4.0" | |
//> using test.dep com.disneystreaming::weaver-cats::0.8.4 | |
package repro | |
import cats.effect.IO | |
import scala.concurrent.duration._ | |
import weaver.SimpleMutableIOSuite | |
object Repro extends SimpleMutableIOSuite { |
This file contains 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.4.0" | |
//> using lib "com.github.zainab-ali::aquascape:0.1.0" | |
import fs2.* | |
import cats.effect.* | |
import aquascape.* | |
object BasicScape extends AquascapeApp.Simple { | |
def stream(using Scape[IO]) = { | |
Stream(1, 2, 3) | |
.stage("Source") |
This file contains 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.4.0" | |
//> using lib "co.fs2::fs2-core:3.9.4" | |
import fs2.* | |
import cats.syntax.all.* | |
import cats.effect.* | |
object Demo extends IOApp.Simple { | |
def combineResources[O, O2](f: Chunk[O] => Resource[IO, O2])( | |
in: Stream[IO, Chunk[O]] |
This file contains 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.4.0" | |
//> using lib "co.fs2::fs2-core:3.9.4" | |
import fs2.* | |
import cats.effect.* | |
import cats.effect.unsafe.implicits.global | |
def infiniteStream: Stream[IO, Unit] = | |
(Stream.unit ++ infiniteStream).pull.echo.stream // vs streamNoScope | |
infiniteStream.compile.drain.unsafeRunSync() |
This file contains 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.4.0" | |
//> using lib "co.fs2::fs2-core:3.9.4" | |
import fs2.* | |
import cats.effect.* | |
import cats.effect.unsafe.implicits.global | |
def infiniteStream: Stream[IO, Unit] = | |
(Stream.unit ++ infiniteStream) | |
.handleErrorWith(err => Stream.unit) |
This file contains 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.3.1 | |
//> using dep co.fs2::fs2-core::3.9.4 | |
import cats.syntax.all.* | |
import cats.effect.IO | |
import fs2.Stream | |
import cats.effect.unsafe.implicits.global | |
Stream(1, 2) | |
.covary[IO] |
This file contains 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
enum Pull { | |
case Done | |
case Output(name: String) | |
case UnconsThen(pull: Pull, f: Option[(String, Pull)] => Pull) | |
case Then(pull: Pull, next: () => Pull) | |
} | |
import Pull._ | |
val done = Done | |
def single(name: String) = Output(name) |
This file contains 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
enum Pull[A] { | |
case Pure[A](value: A) extends Pull[A] | |
case Output(name: String) extends Pull[Unit] | |
case Uncons[A](pull: Pull[A]) extends Pull[Option[(String, Pull[A])]] | |
case FlatMap[A, B](pull: Pull[A], f: A => Pull[B]) extends Pull[B] | |
} | |
import Pull._ | |
val done: Pull[Unit] = Pure(()) | |
def single(name: String): Pull[Unit] = Output(name) |
This file contains 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
package game | |
/** Game logic: | |
* | |
* The game map is a tiled grid. Each tile has something on it. | |
* | |
* Actions: | |
* When a citizen is clicked on, they can be told to do something. | |
* At the moment, they can only chop wood. | |
* |
This file contains 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
package foo | |
import shapeless._ | |
import shapeless.labelled.FieldType | |
import shapeless.ops.hlist._ | |
/** This example zips two hlists together based on their keys and part of their values | |
* | |
* | |
* A left HList of type FieldType[Key, (A, LB)] :: LTail is zipped with a right HList which contains FieldType[Key, (A, RB)] |
NewerOlder