Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nondecreasing export list formatting #313

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src-literatetests/10-tests.blt
Original file line number Diff line number Diff line change
Expand Up @@ -1001,8 +1001,7 @@ module Main
, test7
, test8
, test9
)
where
) where

#test exports-with-comments
module Main
Expand All @@ -1016,8 +1015,7 @@ module Main
-- Test 5
, test5
-- Test 6
)
where
) where

#test simple-export-with-things
module Main (Test(..)) where
Expand All @@ -1035,7 +1033,7 @@ module Main
( Test(Test, a, b)
, foo -- comment2
) -- comment3
where
where

#test export-with-empty-thing
module Main (Test()) where
Expand Down Expand Up @@ -1286,8 +1284,7 @@ module Test
, test9
, test10
-- Test 10
)
where
) where

-- Test
import Data.List ( nub ) -- Test
Expand Down
3 changes: 1 addition & 2 deletions src-literatetests/15-regressions.blt
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,7 @@ module Main
, DataTypeII(DataConstructor)
-- * Haddock heading
, name
)
where
) where

#test type level list

Expand Down
9 changes: 3 additions & 6 deletions src-literatetests/30-tests-context-free.blt
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,7 @@ module Main
, test7
, test8
, test9
)
where
) where

#test exports-with-comments
module Main
Expand All @@ -690,8 +689,7 @@ module Main
-- Test 5
, test5
-- Test 6
)
where
) where

#test simple-export-with-things
module Main (Test(..)) where
Expand Down Expand Up @@ -913,8 +911,7 @@ module Test
, test8
, test9
, test10
)
where
) where

-- Test
import Data.List (nub) -- Test
Expand Down
11 changes: 7 additions & 4 deletions src/Language/Haskell/Brittany/Internal/Layouters/Module.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,21 @@ layoutModule lmod@(L _ mod') = case mod' of
, docWrapNode lmod $ appSep $ case les of
Nothing -> docEmpty
Just x -> layoutLLIEs True x
, docSeparator
, docLit $ Text.pack "where"
]
addAlternative
$ docLines
[ 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