Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

Can't compile the main example #65

Open
ashkan-leo opened this issue Feb 13, 2019 · 2 comments
Open

Can't compile the main example #65

ashkan-leo opened this issue Feb 13, 2019 · 2 comments

Comments

@ashkan-leo
Copy link

ashkan-leo commented Feb 13, 2019

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

@NeQuissimus
Copy link
Member

You're probably way better off using scalaz-zio these days. There is a Scalaz 7 interop module in there, too.

@pkhamutou
Copy link

@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.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants