diff options
author | Maxim Koltsov <kolmax94@gmail.com> | 2020-10-05 21:28:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-05 20:28:37 +0200 |
commit | 84ff4e57eb24b5b5ab95ad7b64419846922e00f7 (patch) | |
tree | ea99f73bb9e6288670b16416cf0ad461bafedd1a /lib | |
parent | 062310c5d3420e58edea1a2d6bbe0f71d18a184e (diff) | |
download | stylish-haskell-84ff4e57eb24b5b5ab95ad7b64419846922e00f7.tar.gz |
Make sorting deriving list optional (#316)
* Make sorting deriving list optional
Not everyone wants their typeclasses sorted.
* Remove redundant code
Co-authored-by: Łukasz Gołębiewski <lukasz.golebiewski@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Language/Haskell/Stylish/Config.hs | 1 | ||||
-rw-r--r-- | lib/Language/Haskell/Stylish/Step/Data.hs | 4 |
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/Language/Haskell/Stylish/Config.hs b/lib/Language/Haskell/Stylish/Config.hs index 333736f..68638a6 100644 --- a/lib/Language/Haskell/Stylish/Config.hs +++ b/lib/Language/Haskell/Stylish/Config.hs @@ -221,6 +221,7 @@ parseRecords c o = Data.step <*> (o A..:? "break_single_constructors" A..!= True) <*> (o A..: "via" >>= parseIndent) <*> (o A..:? "curried_context" A..!= False) + <*> (o A..:? "sort_deriving" A..!= True) <*> pure configMaxColumns) where configMaxColumns = diff --git a/lib/Language/Haskell/Stylish/Step/Data.hs b/lib/Language/Haskell/Stylish/Step/Data.hs index bf39c7c..523389b 100644 --- a/lib/Language/Haskell/Stylish/Step/Data.hs +++ b/lib/Language/Haskell/Stylish/Step/Data.hs @@ -71,6 +71,8 @@ data Config = Config -- ^ Indentation between @via@ clause and start of deriving column start , cCurriedContext :: !Bool -- ^ If true, use curried context. E.g: @allValues :: Enum a => Bounded a => Proxy a -> [a]@ + , cSortDeriving :: !Bool + -- ^ If true, will sort type classes in a @deriving@ list. , cMaxColumns :: !MaxColumns } deriving (Show) @@ -266,7 +268,7 @@ putDeriving Config{..} (L pos clause) = do = clause & deriv_clause_tys & unLocated - & sortBy compareOutputable + & (if cSortDeriving then sortBy compareOutputable else id) & fmap hsib_body headTy = |