tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
944 stars 83 forks source link

Cannot format operators starting with a hash when using UnboxedSums or UnboxedTuples #1062

Closed wismill closed 10 months ago

wismill commented 11 months ago

Describe the bug Ormolu formats ( #<| ) as (#<|) when -XUnboxedSums or -XUnboxedTuples is set, thus the formatted code generates a parser error. I think it applies to any operator starting with #.

To Reproduce

Format the following file with --unsafe (else it fails).

{-# LANGUAGE UnboxedTuples #-}

module Foo (( #<| )) where

( #<| ) :: Int -> Int -> Int
( #<| ) = (+)

The generated code does not compile.

Expected behavior Ormolu should keep the spaces to be valid code, i.e. ( #<| ) should be unchanged.

Environment

wismill commented 10 months ago

@amesgen Thank you, that was fast!