Commit Graph

12 Commits (3f9e9d9bcb07bd3ddfdf8eeec5ff2235007a07b3)

Author SHA1 Message Date
Lennart Spitzner 884c7da97c Allow special layout for HsApp with HsDo/HsSpiceE args 2023-05-02 09:56:39 +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 7ab6a207ae Update OpApp layouting options
- Allow par-spacing for single-operator 1+n-line layout
- Tweak when to flatten operators, i.e. when to allow a flat one-line-each
  layout for the operator sequence "$ $ $ + +".
2023-05-02 09:16:44 +00:00
Lennart Spitzner 99e5aacb5e Discard special case for non-nested OpApp 2023-05-02 09:16:04 +00:00
Lennart Spitzner d29303d4cd Improve one HsLet layout
- Allow parSpacing for single-clause layout
- Allow par/sl layout when no where-clause was present
  (not sure why this was disabled in the first place)
2023-05-02 09:16:04 +00:00
Lennart Spitzner 09ec59eaf9 Fix comment-after-context 2023-05-02 09:16:04 +00:00
Lennart Spitzner 2fef44559e Fix comments moving after "where" 2023-05-02 09:16:04 +00:00
Lennart Spitzner 676695a609 Implement fixity-aware-ops feature 2023-05-02 09:16:03 +00:00
Lennart Spitzner f13a82964a Partially restore retaining-empty-lines behaviour
Currently works for do blocks, multi-line list literals, and
lambda-case cases (apart from top-level blank lines that
never got ignored).
2023-05-02 09:16:03 +00:00
Lennart Spitzner 83b13d61a0 Change behaviour: Less par-spacing for function application 2023-05-02 09:16:03 +00:00
Lennart Spitzner d11141d34d Refactor+Rewrite+Adaptation for ghc-9.2 support 2023-05-02 09:16:03 +00:00
Lennart Spitzner 4e397441b9 Revert "Split tests into individual files"
This reverts commit 21e86adf6e.
2023-05-02 09:16:00 +00:00