tfausak/cabal-gild

Default-extensions get randomly sorted

nikita-volkov opened this issue · 2 comments

I got the following diff after running cabal-gild:

 common base-settings
   default-extensions:
-    NoImplicitPrelude
-    NoMonomorphismRestriction
-    BangPatterns
-    BlockArguments
-    ConstraintKinds
-    DataKinds
-    DefaultSignatures
-    DeriveDataTypeable
-    DeriveFoldable
-    DeriveFunctor
-    DeriveGeneric
-    DeriveTraversable
-    DerivingVia
-    EmptyDataDecls
+    ParallelListComp
+    MultiParamTypeClasses
+    FunctionalDependencies
+    RankNTypes
+    ScopedTypeVariables
     FlexibleContexts
     FlexibleInstances
-    FunctionalDependencies
-    GADTs
+    EmptyDataDecls
+    BangPatterns
+    TemplateHaskell
+    PatternGuards
     GeneralizedNewtypeDeriving
-    InstanceSigs
-    LambdaCase
-    LiberalTypeSynonyms
     MagicHash
-    MultiParamTypeClasses
-    MultiWayIf
-    NumericUnderscores
+    TypeFamilies
+    StandaloneDeriving
+    LiberalTypeSynonyms
+    TypeOperators
+    RecordWildCards
     OverloadedStrings
-    ParallelListComp
-    PatternGuards
+    GADTs
+    UnboxedTuples
+    DeriveDataTypeable
+    DeriveGeneric
+    DefaultSignatures
+    InstanceSigs
     QuasiQuotes
-    RankNTypes
-    RecordWildCards
-    ScopedTypeVariables
-    StandaloneDeriving
-    StrictData
-    TemplateHaskell
     TupleSections
+    MultiWayIf
+    LambdaCase
+    DeriveFunctor
+    DeriveTraversable
+    DeriveFoldable
+    ConstraintKinds
+    DataKinds
+    StrictData
     TypeApplications
-    TypeFamilies
-    TypeOperators
-    UnboxedTuples
+    DerivingVia
+    BlockArguments
+    NumericUnderscores
+    NoMonomorphismRestriction
+    NoImplicitPrelude

Can we have a natural sorting there?

Oh dear, that's very strange. Gild currently defers to Cabal's Ord instance for Extension: https://hackage.haskell.org/package/Cabal-syntax-3.10.2.0/docs/Language-Haskell-Extension.html#t:Extension

I thought that instance would be alphabetical, but it appears to be more or less random. This should be fixable by providing a custom wrapper around Extension, like we do for Language:

newtype Language = Language
{ unwrap :: Extension.Language
}

Thanks for reporting this! I'm a bit embarrassed that I didn't catch it earlier. At any rate, it should be fixed in version 1.0.2.2.