Commit Graph

8 Commits (ghc92)

Author SHA1 Message Date
Lennart Spitzner 4ed3a2f53d Fix a missing comment case with MultiWayIf 2023-05-29 21:00:10 +00:00
Lennart Spitzner 5481e5015f Make use of OpTree for type (signature) layouting, Fix layout
Some more cases that still produced broken layout on interaction
with do-blocks were fixed.
2023-05-29 20:44:01 +00:00
Lennart Spitzner 860c8771ae Fix issue with indentation after block-comments 2023-05-18 15:42:48 +00:00
Lennart Spitzner 2b77142617 Fix layout of type-level list literal 2023-05-03 19:53:19 +00:00
Phil Hazelden 52bde7910f Support promoted type applications.
Closes #370.

Up to GHC 8.10,

    foo @ 'Bar

was a valid type application. In GHC 9 it's not, which means brittany
needs to allow

    foo @'Bar

which it now does.

The reason the space was needed was to allow a promoted type variable at
the head of a type-level list. That is,

    '['Foo]

is invalid syntax, because it initially parses as the character `'['`.
So the promoted type variable was always given a separator at the
beginning, and we'd get

    '[ 'Foo]

which was valid. Now we handle this case by specifically examining the
head of a type-level list; if it's promoted we introduce spaces, so

    '[ 'Foo ]
    '[Foo]

I've added tests for this and some related cases. In doing so I noticed
that unnecessary spaces get added in front of commas in these lists; I
believe that's a separate bug, and I've written a comment explaining why
it happens, but I haven't tried to fix it.

I'm not sure when the first alternates in the `FirstLastSingleton`
and `FirstLast` branches would ever be hit, so I'm not entirely sure if
the separators are necessary there. But since `docSeparator` disappears
at the end of a line and merges with adjacent separators, they should be
harmless.
2023-05-02 09:56:39 +00:00
Lennart Spitzner 05270ecb45 Improve block-comment behaviour (newlines after or not) 2023-05-02 09:16:03 +00:00
Lennart Spitzner d9373ec80e Implement extension support - OverloadedRecordDot 2023-05-02 09:16:03 +00:00
Lennart Spitzner bff9bfb312 Support and use nested file structure for tests 2023-05-02 09:16:03 +00:00