Last active
January 26, 2024 22:51
-
-
Save zainab-ali/b7660816ad97047687af65cfee1eb63a to your computer and use it in GitHub Desktop.
Ensure
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] | |
.debugChunks(formatter = (ch) => s"Before: $ch") | |
.ensure(new Error("!"))(_ => true) | |
.debugChunks(formatter = (ch) => s"After: $ch") | |
.compile | |
.drain | |
.unsafeRunSync() | |
// Before: Chunk(1, 2) | |
// After: Chunk(1) | |
// After: Chunk(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment