0

I am trying to understand a fold example.

val rowStream: Stream[IO, Rows] = ...

rowStream.fold(Right(()): Either[RowError, Unit]) {
    case (Right(_), b) =>
        // completely succeed here
        //b.rows... etc
    case (Left(_), _) =>
        // Fail with Left(RowError)
}
  1. In the case (Right(_), b) => what is b? Shouldn't it just be passing Right() as the case? and how is b allowed to be passed in the case?

  2. Am I correct to say that the Right(()) passed by the fold is the folds initial value, set to a Right of Unit?

Chris
  • 785
  • 10
  • 24

0 Answers0