cdepillabout / pretty-simple

pretty-printer for Haskell data types that have a Show instance
https://hackage.haskell.org/package/pretty-simple
BSD 3-Clause "New" or "Revised" License
243 stars 29 forks source link

Printing of a fractional in scientific notation adds spaces #99

Closed vcanadi closed 3 years ago

vcanadi commented 3 years ago

e.g pShowOpt defaultOutputOptionsNoColor (1e-2 :: Double) results in "1.0 e- 2" and not "1.0e-2" The first one is not readable by default Read instance e.g. read @Double $ unpack $ pShowOpt defaultOutputOptionsNoColor (1e-2 :: Double) *** Exception: Prelude.read: no parse

georgefst commented 3 years ago

Thanks. This is another instance of #75.

cdepillabout commented 3 years ago

I'll close this in favor of #75.

The first one is not readable by default Read instance

Being able to feed the output of pretty-simple into read was never a goal for pretty-simple.

What are you using this for?

I guess it could be somewhat useful, but I've never really thought about it. Up until now, I don't think anyone has ever requested this.

vcanadi commented 3 years ago

I have some amount of static data that is used for unit testing. I've pretty printed it so it is more readable in the *Spec.hs files. Basically, I just wanted json-like line breaks of the data instead of just one single line string you have from Show.

cdepillabout commented 3 years ago

@vcanadi There are other pretty-printing libraries in Haskell, a lot of them require a data type to have a valid Show instance (and don't print in color by default), so it might make more sense for you to use one of them.

For instance, https://hackage.haskell.org/package/pretty-show might be a better fit for you.

A couple other links you might be interested in: