Ticket #193 (closed bug report: fixed)

Opened 4 years ago

Last modified 4 years ago

Poor pretty printing of negative literals

Reported by: NeilMitchell2 Owned by: nibro
Priority: major Milestone:
Component: prettyprinter Version: 1.8.x
Keywords: Cc:

Description

Some HSE things that I saw in HLint:

Prelude Language.Haskell.Exts> prettyPrint $ fromParseResult $ parseFileContents "foo = -1.0" "module Main (main) where\nfoo = (- 1.0)"

Prelude Language.Haskell.Exts> prettyPrint $ fromParseResult $ parseFileContents "foo = (-1.0)" "module Main (main) where\nfoo = ((- 1.0))"

When you pretty-print negative literals it seems you just add brackets - that's not always necessary and causes problems for HLint.

Also there is a space between the "-" and the "1.0" in the output. It's not wrong, but I find it very ugly - no one would ever write numeric literals in that way.

Change History

Changed 4 years ago by nibro

  • status changed from new to closed
  • resolution set to fixed

I did a major overhaul of precedences for expressions, it's now much more accurate and far fewer redundant brackets are inserted.

One case remains, which is truly a special case that would require a lot of extra machinery to solve: NegApp? still gets bracketed when appearing first in an infix expression, e.g.

Prelude Language.Haskell.Exts> prettyPrint $ fromParseResult $ parseFileContents "foo = -1.0+2" "module Main (main) where\nfoo = (-1.0) + 2"

Holler if that's a major problem.

Note: See TracTickets for help on using tickets.