ioeffect
ioeffect copied to clipboard
Can't compile the main example
I can't compile the example code provided in the README. I get the following compilation error:
[error] /MyApp.scala:10: overriding method run in trait SafeApp of type (args: List[String])scalaz.ioeffect.IO[scalaz.ioeffect.Void, MyApp.ExitStatus];
[error] method run has incompatible type
[error] def run(args: List[String]): IO[Void, ExitStatus] =
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 2 s, completed Feb 13, 2019 4:34:13 PM
And the following in IntelliJ:
Overriding type List[String] => IO[Void, MyApp.ExitStatus] does not conform to base type List[String] => IO[ioeffect.Void, SafeApp.this.ExitStatus]
Just to be clear, here is the example code from the README that I'm trying to run:
import scalaz.ioeffect.{IO, SafeApp}
import scalaz.ioeffect.console._
import java.io.IOException
object MyApp extends SafeApp {
def run(args: List[String]): IO[Void, ExitStatus] =
myAppLogic.attempt.map(_.fold(_ => 1, _ => 0)).map(ExitStatus.ExitNow(_))
def myAppLogic: IO[IOException, Unit] =
for {
_ <- putStrLn("Hello! What is your name?")
n <- getStrLn
_ <- putStrLn("Hello, " + n + ", good to meet you!")
} yield ()
}
I am using Scala 2.11.7 and Scalaz 7.2.27
You're probably way better off using scalaz-zio these days. There is a Scalaz 7 interop module in there, too.
@ashkan-leo you have this error because your Void
is not scalaz.ioeffect.Void
but java.lang.Void
.
If you import import scalaz.ioeffect.Void
it will compile.