tweag / ormolu

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

Feature request: support fixing small syntax errors #436

Open scott-fleischman opened 4 years ago

scott-fleischman commented 4 years ago

I have been experimenting using ormolu with "format on save" in my editor and find that it is quite convenient for relieving my mind from having to make lots of micro-decisions on formatting choices. I can just write valid code and save, and it formats it nicely enough.

And if I want to make a single-line expression into a multi-line one, I can add a line break somewhere in the middle, save again, and I get the multi-line version.

In some cases, such as adding an item to a list (whether it be an actual list [] or just a list of module exports) might be nice if I add an extra comma or forget one, that omolu tries to fix the problem for me, by adding the comma or taking it away.

While this certainly wouldn't work for the general case, it might be nicer than just reporting an error for cases where the fix is not too difficult.

I realize this might not be very practical but for a few specific cases, if any at all, but I thought I would add it here as something "nice to have".

neongreen commented 4 years ago

I think it's a good idea that will be very hard to implement because we're using GHC's parser and it won't let us get away with missing commas.