From 67b87106dd5fbc99f82199bae7418f1ab9ddf5f7 Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Sun, 22 Mar 2020 13:06:04 +0800 Subject: [PATCH] nondecreasing export list formatting --- src-literatetests/10-tests.blt | 11 ++++------- src-literatetests/15-regressions.blt | 3 +-- src-literatetests/30-tests-context-free.blt | 9 +++------ .../Haskell/Brittany/Internal/Layouters/Module.hs | 15 +++++++++------ 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src-literatetests/10-tests.blt b/src-literatetests/10-tests.blt index a3d1138c..be8ce529 100644 --- a/src-literatetests/10-tests.blt +++ b/src-literatetests/10-tests.blt @@ -1001,8 +1001,7 @@ module Main , test7 , test8 , test9 - ) -where + ) where #test exports-with-comments module Main @@ -1016,8 +1015,7 @@ module Main -- Test 5 , test5 -- Test 6 - ) -where + ) where #test simple-export-with-things module Main (Test(..)) where @@ -1035,7 +1033,7 @@ module Main ( Test(Test, a, b) , foo -- comment2 ) -- comment3 -where + where #test export-with-empty-thing module Main (Test()) where @@ -1286,8 +1284,7 @@ module Test , test9 , test10 -- Test 10 - ) -where + ) where -- Test import Data.List ( nub ) -- Test diff --git a/src-literatetests/15-regressions.blt b/src-literatetests/15-regressions.blt index e4c1b7c6..e09e41b3 100644 --- a/src-literatetests/15-regressions.blt +++ b/src-literatetests/15-regressions.blt @@ -831,8 +831,7 @@ module Main , DataTypeII(DataConstructor) -- * Haddock heading , name - ) -where + ) where #test type level list diff --git a/src-literatetests/30-tests-context-free.blt b/src-literatetests/30-tests-context-free.blt index ba84a7c8..18649a1a 100644 --- a/src-literatetests/30-tests-context-free.blt +++ b/src-literatetests/30-tests-context-free.blt @@ -675,8 +675,7 @@ module Main , test7 , test8 , test9 - ) -where + ) where #test exports-with-comments module Main @@ -690,8 +689,7 @@ module Main -- Test 5 , test5 -- Test 6 - ) -where + ) where #test simple-export-with-things module Main (Test(..)) where @@ -913,8 +911,7 @@ module Test , test8 , test9 , test10 - ) -where + ) where -- Test import Data.List (nub) -- Test diff --git a/src/Language/Haskell/Brittany/Internal/Layouters/Module.hs b/src/Language/Haskell/Brittany/Internal/Layouters/Module.hs index cb82c75f..bd675dde 100644 --- a/src/Language/Haskell/Brittany/Internal/Layouters/Module.hs +++ b/src/Language/Haskell/Brittany/Internal/Layouters/Module.hs @@ -46,9 +46,10 @@ layoutModule lmod@(L _ mod') = case mod' of $ docSeq [ appSep $ docLit $ Text.pack "module" , appSep $ docLit tn - , docWrapNode lmod $ appSep $ case les of + , (docWrapNode lmod $ appSep $ case les of Nothing -> docEmpty - Just x -> layoutLLIEs True x + Just x -> layoutLLIEs True x) + , docSeparator , docLit $ Text.pack "where" ] addAlternative @@ -56,11 +57,13 @@ layoutModule lmod@(L _ mod') = case mod' of [ docAddBaseY BrIndentRegular $ docPar (docSeq [appSep $ docLit $ Text.pack "module", docLit tn] ) - (docWrapNode lmod $ case les of - Nothing -> docEmpty - Just x -> layoutLLIEs False x + (docSeq [ docWrapNode lmod $ case les of + Nothing -> docEmpty + Just x -> layoutLLIEs False x + , docSeparator + , docLit $ Text.pack "where" + ] ) - , docLit $ Text.pack "where" ] ] : map layoutImport imports