Skip to content

Instantly share code, notes, and snippets.

@qingwei91
Created January 27, 2023 08:54
Show Gist options
  • Save qingwei91/c45eaf95f66dd2735e1e472e7a586d01 to your computer and use it in GitHub Desktop.
Save qingwei91/c45eaf95f66dd2735e1e472e7a586d01 to your computer and use it in GitHub Desktop.
Resource type
val fileR: Resource[IO, File] = ...
val socketR1: Resource[IO, Socket] = ...
val socketR2: Resource[IO, Socket] = ...
(for {
file <- fileR
sock1 <- socketR1
sock2 <- socketR2
} yield (file, sock1, sock2)).use {
case (file, socket1, socket2) =>
// do your stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment