Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

showLinesStdOut and friends could keep the elements unchanged #1569

Closed
kubukoz opened this issue Aug 28, 2019 · 5 comments · Fixed by #1727
Closed

showLinesStdOut and friends could keep the elements unchanged #1569

kubukoz opened this issue Aug 28, 2019 · 5 comments · Fixed by #1727

Comments

@kubukoz
Copy link
Member

kubukoz commented Aug 28, 2019

Currently showLinesStdOut uses evalMap to print each element, discarding its value. I think these operators would be much more useful if they kept the original elements (so that there's a nice and easy way to debug the values of a stream at a stage without having to reimplement showLinesStdOut with evalTap).

@ChristopherDavenport
Copy link
Member

.observe lets you have this semantic rather than passing through what is effectively an outlet of values.

@kubukoz
Copy link
Member Author

kubukoz commented Aug 28, 2019

Right, .observe(_.showLinesStdOut) does the job. It would be nice to have a faster way of doing this, especially repeatedly, like .through(debug)... we could have a pipe like that in the package object or Stream/Pipe's companion.

@mpilquist
Copy link
Member

I like making debugging simpler. Signature of debug could be tricky. Where would it write elements? Does it need to take a String => F[Unit]?

@kubukoz
Copy link
Member Author

kubukoz commented Aug 29, 2019

I'd say we could add a specific one for starters (just debug(tag: String) that prints to stdout) and that'll be it... and maybe debugToString that won't require Show, and just toString the elements before printing.

A function for debugging that takes String => F[Unit] would be pretty similar to evalTap, so I'm not sure it'd be worth the hassle... but anything that allows skipping s => Sync[F].delay(println("tag: " + s)) will be a welcome change.

@kubukoz
Copy link
Member Author

kubukoz commented Dec 28, 2019

The greatest problem with observe is that it requires Concurrent, IMO. I think we could start with def debug(tag: String): Stream[F, O] that outputs $tag: $elem to stdout.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants