yav / pretty-show

Tools for working with derived Show instances in Haskell.
MIT License
57 stars 15 forks source link

Fix treatment of negative number literals inside deep costructor applications #18

Closed sergv closed 8 years ago

sergv commented 8 years ago

Currently ppsh cannot parse the following

FooCostructorWithLongName {veryLongFieldName = [(-1 :| [],(2 :| []) :| [])]}

However, it can succesfully parse and prettyprint after small change:

FooCostructorWithLongName {veryLongFieldName = [(1 :| [],(2 :| []) :| [])]}

As far as I know, only numbers in Show output can be preceded by the minus sign, therefore it makes sense to move minus closer to numbers in order to reduce parser's confusion.

yav commented 8 years ago

Hi, thank you for reporting this and submitting a patch. I fixed the issue by increasing the precedence of unary minus. This was a slightly smaller change, and it accepts slightly more inputs, although I think you are entirely right in that the only likely useful case is negating numbers. Let me know if this doesn't work as expected. I put the new version on hackage---version 1.6.10.

sergv commented 8 years ago

It works well, thanks :+1: