tweag / ormolu

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

Group imports with same module name #552

Closed guibou closed 4 years ago

guibou commented 4 years ago

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

The following multiples imports

import Foo (a, c)
import Foo (b)

in currently unchanged by ormolu.

Describe the solution you'd like

I'd like ormolu to group the imports when the context is the same (e.g. same module imported, same qualification and same alias) such as:

import Foo(a, b, c)

Describe alternatives you've considered

The current implementation can be left unchanged.

basile-henry commented 4 years ago

I think it's a good idea! :smile: But doesn't this go against Ormolu trying to keep the AST of the module the same while formatting it? Or maybe this is not something Ormolu tries to achieve anymore?

mrkkrp commented 4 years ago

Things like this are possible, but it is true that it's a bit more work because we need to take these transformations into account when we check that AST has not changed. We already do this because e.g. we sort import statements.

mrkkrp commented 4 years ago

Duplicate of #414.