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

allow non-balanced brackets, parens, etc #27

Open cdepillabout opened 6 years ago

cdepillabout commented 6 years ago

Pretty-simple doesn't currently allow non-balanced brackets, parens, etc.

This should be considered a bug. This is also related to #5.

dminuoso commented 5 years ago

Since pretty-simple is by design for data types with a Show instance I do not consider it a bug.

The Haskell Report has the following to say about Show:

The result of show is a syntactically correct Haskell expression containing only constants, given the fixity
declarations in force at the point where the type is declared.

We can reasonably expect the input to be balanced.

cdepillabout commented 5 years ago

@dminuoso pretty-simple is designed for data types with a Show instance, but it is also designed to be more flexible than other pretty-printing libraries. It should try it's hardest to pretty-print anything, even if it is not syntactically correct.

There are many commonly used data types with non-syntactically-correct Show instances, and pretty-simple should ideally handle them. pretty-simple should also ideally not choke on non-balanced brackets, parens, etc.

cdepillabout commented 5 years ago

Here is an example of this failing to pretty-print something with non-balanced parenthesis:

$ ghci
> import Text.Pretty.Simple
> import Data.Text.Lazy
> putStrLn $ unpack $  pString "Just \"hello\" ) 3345"
Just "hello"

You can see that everything after the ) character doesn't get printed. This should be fixed.

cdepillabout commented 4 years ago

52 is another instance of things being dropped after non-balanced parenthesis. This should really be fixed.