Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enum List.Nil compile error: Values of types List[Nothing] and MyList[Int] cannot be compared with == or != #680

Open
maudslice opened this issue Aug 1, 2023 · 1 comment

Comments

@maudslice
Copy link

Hello, When I try to copy the fpinscala code into my project, my IDE shows some compile errors, like the title, When the List.Nil appears to the left of a case statement in a pattern match, the compiler tells me that Values of types MyList[Nothing] and MyList[Int] cannot be compared with == or !=

  val factorialREPL: IO[Unit] = sequence_(
    PrintLine(helpstring),
    ReadLine.doWhile: line =>
      val ok = line != "q"
      when(ok):
        for
          n <- factorial(line.toInt)
          _ <- PrintLine("factorial: " + n)
        yield ()
  )

this code IDE show 4 error: Not found: type line; an identifier expected, but 'val' found; Not found: ok; an identifier expected, but 'for' found.
but when I pull down the whole project, the errors are compilable, I'm very puzzled, and I'd really like to get your help and advice!

@maudslice maudslice changed the title enum List.Nil compile error: Values of types MyList[Nothing] and MyList[Int] cannot be compared with == or != enum List.Nil compile error: Values of types List[Nothing] and MyList[Int] cannot be compared with == or != Aug 1, 2023
@maudslice
Copy link
Author

my env:
scalaVersion: 3.2.1
jdk: 17
build tool: sbt
IDE: IntelliJ IDEA 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant