Skip to content

Why does Writer.tell return Writer[T, Unit] ? #4236

Answered by armanbilge
atais asked this question in Q&A
Discussion options

You must be logged in to vote

Maybe you are looking for as? :)

val foo: Writer[List[MappingError], Foo] = Writer.tell(List(someError)).as(fooValue)

More generally you can compose using flatMap in a for-comprehension:

for {
  foo <- Writer.value(fooValue)
  _ <- Writer.tell(List(someError))
  _ <- Writer.tell(List(anotherError))
  bar <- Writer.value(barValue)
} yield foo

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by atais
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #4235 on June 14, 2022 17:32.