Skip to content

Commit

Permalink
Always render imports as the first field of a section (fixes #486)
Browse files Browse the repository at this point in the history
  • Loading branch information
sol committed Mar 28, 2022
1 parent 68ec2bd commit d9cbc10
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Hpack/Render.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ import qualified Data.Map.Lazy as Map
import Hpack.Util
import Hpack.Config
import Hpack.Render.Hints
import Hpack.Render.Dsl
import Hpack.Render.Dsl hiding (sortFieldsBy)
import qualified Hpack.Render.Dsl as Dsl

renderPackage :: [String] -> Package -> String
renderPackage oldCabalFile = renderPackageWith settings alignment formattingHintsFieldOrder formattingHintsSectionsFieldOrder
Expand Down Expand Up @@ -415,3 +416,6 @@ renderPaths = LineSeparatedList . map renderPath

needsQuoting :: FilePath -> Bool
needsQuoting = any (\x -> isSpace x || x == ',')

sortFieldsBy :: [String] -> [Element] -> [Element]
sortFieldsBy existingFieldOrder = Dsl.sortFieldsBy ("import" : existingFieldOrder)

0 comments on commit d9cbc10

Please sign in to comment.