Skip to content

Commit

Permalink
Try out for comprehension for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
olivergrabinski committed Aug 3, 2023
1 parent 3053b0b commit d7181fe
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,20 @@ final class Batch[SinkFormat](
}

override def apply(elements: Chunk[Elem[GraphResource]]): Task[Chunk[Elem[Unit]]] =
query(elements)
.flatMap {
case Some(fullGraph) =>
elements.traverse { elem =>
elem.evalMapFilter { gr =>
replaceGraph(gr, fullGraph).flatMap(transform)
}
}
case None =>
Task.pure(elements.map(_.drop))
}
.flatMap(sink)
}
for {
graph <- query(elements)
transformed <- graph match {
case Some(fullGraph) =>
elements.traverse { elem =>
elem.evalMapFilter { gr =>
replaceGraph(gr, fullGraph).flatMap(transform)
}
}
case None =>
Task.pure(elements.map(_.drop))
}
sank <- sink(transformed)
} yield sank

object CompositeSink {

Expand Down

0 comments on commit d7181fe

Please sign in to comment.