Adds Show[Stream]#775
Conversation
Current coverage is
|
|
Looks great to me! Thanks for ensuring referential transparency. 👍 |
There was a problem hiding this comment.
Using the .show syntax here will result in an extra allocation for the ShowOps object, right? In this particular case that probably doesn't matter, but it may be worth having a convention of not using syntax when it comes at an allocation cost in Cats. I don't know. What do people think?
|
I'm going to go ahead and merge. This is a useful instance and we can always revisit the syntax usage later. |
|
@ceedubs - sorry for the delay in responding. Thanks for merging! With regard to the use of the I'm just wondering aloud whether it might be better to investigate what might be possible with value classes/simulacrum/machinist to reduce/remove the cost of using syntax here, instead of imposing the convention and fall back to the convention if we can't get the desired results. It would be nice for users of cats not to have to consider this also so it would be valuable in that sense too. |
Adds a
Showinstance forStream.Of note, unlike
Stream.toString, this proposed implementation is referentially transparent.A test exists for this property.
I thought about adding some checks in that test to demonstrate that
toStringexhibits behaviour that violates referential transparency, but I thought that would be too brittle to included in this test, as if a future Scala version rectifies this behaviour inStream, then the test might break, which might not be nice. It is straightforward to add something that shows this however.