Add pretty_print methods to Result and Maybe#189
Conversation
|
I'm positive about this, but can you make it an extension? |
|
I can, but I'm curious as to why. Here's my case for it not being an extension:
If you still want it as an extension, that's fine, its your project. I'm skeptical of the tradeoff involved, and urge you to reconsider, or at least explain your decision. |
I don't have strong feelings if it's enabled by default, I just don't like when code is cluttered with significantly different things. My suggestion is trying to extract representation-related stuff to a separate file, similarly to how inspection is handled in dry-types. That said, it's not obvious to me which approach is better in the long run, I'll play around with extension to see if I actually like it. I'll send a PR later today |
|
Thanks for putting this together, @paul! And thanks for taking care of it, @flash-gordon :) FWIW, I'd love to have the pretty printing support enabled by default. It's a great example of how we can make our gems better to interact with, and one I'd love to carry over to the rest of our gems too. ❤️ |
|
@paul @timriley yeah, thanks for bringing it up. I spent some time fruitlessly trying to bend pp to print Some[
1,
2,
... # many more values
100
]Instead of its defaults: Some(
[1,
2,
# ...
100])Alas, it turned out to be less trivial so I gave up. I've finished the implementation for all monads in an auto-loaded extensions #190 I think it's good to go. If you folks don't have objections, I'll releases it later today |
Adds
#pretty_printto Result and Maybe, so PP looks good.Examples:
Also, Pry and IRB leverage PP for their output, and even can color it, so this lets it color the monads, and the contents of the monads:
Before:
After: