lspitzner / brittany

haskell source code formatter
GNU Affero General Public License v3.0
690 stars 72 forks source link

Parsing failure on some type equality constructs #277

Open hasufell opened 4 years ago

hasufell commented 4 years ago
github_ :: ( MonadIO m
              , ParseResponse mt req, res ~ Either Error req,
                ro ~ 'RO)
           => (GenRequest mt ro req)
           -> ExceptT Error m req
github_ req = do
  ExceptT $ liftIO $ github' req

fails to be parsed/formatted with:

ERROR: brittany pretty printer returned syntactically invalid result.
ERROR: encountered unknown syntactical constructs:
HsOpTy{} at lib/GHup.hs:411:17-24
github_ :: ( MonadIO m
              , ParseResponse mt req, res ~ Either Error req, ro ~ 'RO)
           => (GenRequest mt ro req)
           -> ExceptT Error m req
github_ req = do
  ExceptT $ liftIO $ github' req

works fine. Both compile and are the same in GHC.

lspitzner commented 4 years ago

Thanks for the report. I can reproduce. On master this is down to a warning by the power of the errors-fall-back-on-exactprint feature, but that simply leaves it non-reformatted.

It is possible to work around this by prefixing the (~), (in this case (~) ro 'RO) but that is a bit sad. Need to implement -XTypeOperator support, see #271.

Even though technically a duplicate, I'll leave this open because type equality might be a bit more common than other type operators. And maybe we can prioritise this over the full type operators; those might be a can of worms if we wish to support precedences.