tweag / ormolu

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

Space inserted between INLINE pragma and declaration only if it has Haddock #463

Open michaelpj opened 4 years ago

michaelpj commented 4 years ago

This gets left as it is:

{-# INLINE foo #-}
foo :: Int
foo = 1

But this gets reformatted:

{-# INLINE foo #-}
-- | This is foo
foo :: Int
foo = 1

to

{-# INLINE foo #-}

-- | This is foo
foo :: Int
foo = 1

It's also left alone if I change the Haddock comment into a non-Haddock comment.

I think the pragma belongs "with" the declaration. This seems to happen in the cases where there isn't a Haddock comment, and I don't think having one should change it.

mrkkrp commented 4 years ago

This is the first time I see pragmas placed like this. To me this is very low priority, you probably should just put the pragmas in more conventional locations, that is, any location without putting Haddocks between the pragma and the declaration.

michaelpj commented 4 years ago

I can of course put them somewhere else, but I don't think that it's an especially weird place to put them. They're comments that talk about the function, there's no obvious reason either they or the Haddocks should come first.

(And not to snark, but a small amount of searching turned up https://github.com/tweag/linear-types/blob/8c3f95fc9fe8f843b71f96b4c8d6e8a2bb5fecfa/Examples/src/Cursors/PureStorable.hs#L59 amongst others :) )

mrkkrp commented 4 years ago

Yeah, all I say is that it's relatively low priority.