brittany icon indicating copy to clipboard operation
brittany copied to clipboard

Parsing failure on some type equality constructs

Open hasufell opened this issue 5 years ago • 1 comments

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.

hasufell avatar Jan 31 '20 16:01 hasufell

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.

lspitzner avatar Jan 31 '20 16:01 lspitzner