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)
}
In the
case (Right(_), b) =>
what isb
? Shouldn't it just be passingRight()
as the case? and how isb
allowed to be passed in the case?Am I correct to say that the
Right(())
passed by thefold
is the folds initial value, set to aRight
of Unit?