From 84ff4e57eb24b5b5ab95ad7b64419846922e00f7 Mon Sep 17 00:00:00 2001 From: Maxim Koltsov Date: Mon, 5 Oct 2020 21:28:37 +0300 Subject: Make sorting deriving list optional (#316) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Make sorting deriving list optional Not everyone wants their typeclasses sorted. * Remove redundant code Co-authored-by: Łukasz Gołębiewski --- lib/Language/Haskell/Stylish/Config.hs | 1 + lib/Language/Haskell/Stylish/Step/Data.hs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') 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 = -- cgit v1.2.3