Skip to content

Commit

Permalink
Fix bug in compact import handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonidas Loucas committed Jul 3, 2020
1 parent 09df79e commit 7d52035
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/Floskell/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,13 +1021,17 @@ instance Pretty ImportSpecList where
withGroupH ctx op open close . inter (operatorH ctx sep) $ map pretty xs
case imports of
xs@[] | zeroSpec -> compactList Other "imp-compact-(" "(" ")" "," xs
xs@[_] | oneSpec -> compactList Other "imp-compact-(" "(" ")" "," xs
xs@[x] | oneSpec && isCompactImport1 x -> compactList Other "imp-compact-(" "(" ")" "," xs
_ ->
groupV Other "(" ")" $
listVinternal Other "," imports
isCompactImport1 x = case x of
IVar {} -> True
IAbs {} -> True
_ -> False

instance Pretty ImportSpec where
prettyPrint (IThingAll _ ivar) = do
prettyPrint (IThingAll _ ivar) =
withLayout cfgLayoutImportSpecInnerList
(do
withGroup Other "import-all-cons" "" "" $ pretty ivar
Expand All @@ -1047,12 +1051,19 @@ instance Pretty ImportSpec where
pretty ivar
withLayout cfgLayoutImportSpecInnerList (flex vars') (vertical vars')
where
flex vars' = withIndentFlex cfgIndentImportSpecInnerList $ do
flex vars' = withIndentFlex cfgIndentImportSpecInnerList $
listAutoWrap Other "(" ")" "," vars'

vertical vars' = withIndent cfgIndentImportSpecInnerList True $ do
groupV Other "(" ")" $
listVinternal Other "," vars'
(zeroSpec, oneSpec) <- getConfig (cfgOptionImportCompactSpecialization . cfgOptions)
let compactList ctx op open close sep xs =
withGroupH ctx op open close . inter (operatorH ctx sep) $ map pretty xs
case vars' of
xs@[] | zeroSpec -> compactList Other "imp-compact-(" "(" ")" "," xs
xs@[_] | oneSpec -> compactList Other "imp-compact-(" "(" ")" "," xs
_ ->
groupV Other "(" ")" $
listVinternal Other "," vars'

instance Pretty CName

Expand Down

0 comments on commit 7d52035

Please sign in to comment.