Last active
June 15, 2019 13:59
-
-
Save nicmart/6994f496294c3d25c563120fccd4ef94 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 scalaz.zio.IO | |
import scala.io.StdIn | |
object Example { | |
case class MyError(text: String) | |
def readOption(availableOptions: Set[String]): IO[InvalidOption, String] = | |
IO.effectTotal(StdIn.readLine()).flatMap { input => | |
if (availableOptions.contains(input)) IO.succeed(input) | |
else IO.fail(InvalidOption(input, availableOptions)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment