Bodigrim / linear-builder

Strict Text and ByteString builder, which hides mutable buffer behind linear types and takes amortized linear time.
https://hackage.haskell.org/package/text-builder-linear
BSD 3-Clause "New" or "Revised" License
88 stars 4 forks source link

Add (#<|) and deprecate its alias (<|#) #9

Closed wismill closed 1 year ago

wismill commented 1 year ago

Previously the documentation stated that (#<|) was not supported by the parser. It turns out it is a silly interaction with -XUnboxedTuples. Adding extra spacing between the parentheses and the function fixes the issue.

This commit adds (#<|) and makes (<|#) its deprecated alias.

wismill commented 1 year ago

Note: fourmolu does not support this fix and suppresses the spaces in ( #<| ). See tweag/ormolu#1062.

For now, I use fourmolu’s special comments to disable formatting at the corresponding lines.

Bodigrim commented 1 year ago

Thanks, interesting!

Could you please mention the caveat about spaces around ( #<| ) in documentation? Lest users are tricked the same way I was.

I'm a bit reluctant to accumulate pragmas and would rather wait for Ormolu / Formolu to fix the formatting issue.

wismill commented 1 year ago

Could you please mention the caveat about spaces around ( #<| ) in documentation?

I added a mention about the caveat in the doc and in the code.

Lest users are tricked the same way I was.

I discovered this caveat by mere curiosity: GHC had no issue with a #<| b but had with (#<|). So it is indeed not obvious!

I'm a bit reluctant to accumulate pragmas and would rather wait for Ormolu / Formolu to fix the formatting issue.

Agreed. I reduced to only one comment at the beginning of the file. A fix is already in the work, see tweag/ormolu#1063. I do not think you should wait for a formatting tool to be fixed to merge this PR, as it introduces a deprecation in a young library: the sooner you release, the lesser users will need migration.

wismill commented 1 year ago

Rebased. I tested with success formatting with fourmolu using the patch at tweag/ormolu#1063.

Bodigrim commented 1 year ago

Waiting for https://github.com/fourmolu/fourmolu/pull/369 to be released.

wismill commented 1 year ago

Fourmolu 0.14 has been released

wismill commented 1 year ago

I removed the commit with the special Fourmolu comments.