fourmolu icon indicating copy to clipboard operation
fourmolu copied to clipboard

Ormolu compatibility

Open georgefst opened this issue 5 years ago • 2 comments

Currently, behaviour deviates from Ormolu (with this config) in the following ways:

  • #6: Changes a specific rare edge case (do block as the left operand of an infix operator), where Ormolu + 4-space indentation causes an unsafe formatting (modified AST).
    • EDIT: possibly related to https://github.com/tweag/ormolu/issues/528
  • #30: In single-line mode, we don't insert leading spaces:
    {- | haddock
    comment
    -}
    
    becomes:
    -- | haddock
    --comment
    
    rather than:
    -- | haddock
    -- comment
    
    Replicating Ormolu's behaviour here would be possible. The implementation would just get very messy. Besides, we still have the property that we won't modify code which has already been formatted by Ormolu. And I'm admittedly a bit ambivalent because I really can't see the argument for replacing multi-line comments with multiple single-line ones in the first place.
  • #37: The fact that we round down upon indenting means that some lines which wouldn't start in an even column with Ormolu do with Fourmolu. I'm yet to find an example of this which looks like code any human would actually write.

Each of these changes has elements which it may be worth at least attempting to upstream.

georgefst avatar Oct 01 '20 01:10 georgefst

TODO: Maybe move this into a Wiki page?

brandonchinn178 avatar Apr 17 '22 03:04 brandonchinn178

TODO: Maybe move this into a Wiki page?

Perhaps. Ideally I'd like to just get rid of each inconsistency. But that might not happen any time soon.

georgefst avatar Apr 17 '22 09:04 georgefst