Last active
July 14, 2019 07:47
-
-
Save ghostdogpr/7fd8aba532866abbbb2527b26af0e9b5 to your computer and use it in GitHub Desktop.
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
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