Skip to content

Compiler error on explicit types in for-comprehension #1

@ksilin

Description

@ksilin

Not an issue with your code, but a slight change leads to a compiler error which I cannot understand or fix. Perhaps you can shed some light on it.

adding types inside the for comprehension fails to compile:

      val summed = for {
        resultOne: Int <- one
        resultTwo: Int <- two
      } yield {
        resultOne + resultTwo
      }

The compiler error is: value filter is not a member of com.example.monadT.OptionTransformer[scala.concurrent.Future,Int] [error] resultOne: Int <- one

while this compiles and runs:

      val summed = for {
        resultOne <- one
        resultTwo <- two
      } yield {
        resultOne + resultTwo
      }

How is filter involved here? How would I fix it and still keep explicit types?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions