tweag / ormolu

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

Could imports of the same package be grouped when using `PackageImports` ? #905

Closed silky closed 2 years ago

silky commented 2 years ago

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

Consider:

{-# LANGUAGE PackageImports #-}

import "servant-server" Servant (Context (EmptyContext), Get, Handler, NamedRoutes, type (:>))
import "servant" Servant.API.Generic ((:-))
import "servant-blaze" Servant.HTML.Blaze (HTML)
import "servant-server" Servant.Server.Generic (AsServerT, genericServeTWithContext)

Ormolu formats them this way, when it might be nice if the imports from the same package (servant-server) where together?

Describe the solution you'd like

To sort first by package name, instead of module name, when PackageImports is turned on.

Describe alternatives you've considered

n/a

Additional context

n/a

-- edit: ( Removing the style tag because I think I can only add that as I'm a member of tweag, not because of the repository settings; I'll leave it to a maintainer to make that call 😅 )

matthew-healy commented 2 years ago

I'm going to take a look at this issue.