Skip to content

Instantly share code, notes, and snippets.

@ghostdogpr
Last active July 14, 2019 07:47
Show Gist options
  • Save ghostdogpr/7fd8aba532866abbbb2527b26af0e9b5 to your computer and use it in GitHub Desktop.
Save ghostdogpr/7fd8aba532866abbbb2527b26af0e9b5 to your computer and use it in GitHub Desktop.
import scala.io.{ Codec, Source }
import zio.{ App, console, ZIO }
import zio.blocking._
object SampleApp extends App {
def getResource(path: String): ZIO[Blocking, Throwable, String] = effectBlocking {
Source.fromResource(path)(Codec.UTF8).getLines.mkString
}
override def run(args: List[String]): ZIO[Environment, Nothing, Int] =
getResource("test.txt").foldM(ex => console.putStrLn(ex.toString).const(-1), res => console.putStrLn(res).const(0))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment