tweag / ormolu

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

Region formatting within `where` clauses #572

Closed jinwoo closed 4 years ago

jinwoo commented 4 years ago

Is your feature request related to a problem? Please describe.

https://github.com/tweag/ormolu/issues/516 now allows formatting a certain part of the file and it's a big improvement. This feature request is similar to that but applies to regions in a where clause rather than to top-level regions.

Sometimes I want to format only a certain inner function in a where clause (e.g., when adding a new inner function to an existing file). But it's not currently possible because it is not a top-level entity. It will be a usability improvement to be able to do that.

Describe the solution you'd like

In a similar way https://github.com/tweag/ormolu/issues/516 handles top-level entities.

Describe alternatives you've considered

A workaround is to temporarily move the inner function to the top-level, format it, move it back to the where clause, and then indent appropriately. But it's inconvenient.

Avi-D-coder commented 4 years ago

I believe this is needed for let as well.