Skip to content

Commit

Permalink
Remove unnecessary special purpose top level marking functions
Browse files Browse the repository at this point in the history
  • Loading branch information
alanz committed Dec 16, 2024
1 parent a9d9647 commit e2d3da7
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions src/Language/Haskell/GHC/ExactPrint/ExactPrint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1472,11 +1472,6 @@ commentAllocationIn ss = do
markAnnotatedWithLayout :: (Monad m, Monoid w) => ExactPrint ast => ast -> EP w m ast
markAnnotatedWithLayout a = setLayoutBoth $ markAnnotated a
-- ---------------------------------------------------------------------
markTopLevelList :: (Monad m, Monoid w) => ExactPrint ast => [ast] -> EP w m [ast]
markTopLevelList ls = mapM (\a -> setLayoutTopLevelP $ markAnnotated a) ls
-- ---------------------------------------------------------------------
-- End of utility functions
-- ---------------------------------------------------------------------
Expand Down Expand Up @@ -1548,11 +1543,11 @@ instance ExactPrint (HsModule GhcPs) where
an0 <- markLensTok an lam_mod
m' <- markAnnotated m
mdeprec' <- setLayoutTopLevelP $ markAnnotated mdeprec
mdeprec' <- markAnnotated mdeprec
mexports' <- setLayoutTopLevelP $ markAnnotated mexports
mexports' <- markAnnotated mexports
an1 <- setLayoutTopLevelP $ markLensTok an0 lam_where
an1 <- markLensTok an0 lam_where
return (an1, Just m', mdeprec', mexports')
Expand Down Expand Up @@ -1603,8 +1598,8 @@ instance ExactPrint HsModuleImpDecls where
setAnnotationAnchor mid _anc _ cs = mid { id_cs = priorComments cs ++ getFollowingComments cs }
`debug` ("HsModuleImpDecls.setAnnotationAnchor:cs=" ++ showAst cs)
exact (HsModuleImpDecls cs imports decls) = do
imports' <- markTopLevelList imports
decls' <- markTopLevelList (filter notDocDecl decls)
imports' <- mapM markAnnotated imports
decls' <- mapM markAnnotated (filter notDocDecl decls)
return (HsModuleImpDecls cs imports' decls')
Expand Down Expand Up @@ -4908,18 +4903,6 @@ setLayoutBoth k = do
, pLHS = oldAnchorOffset} )
k <* reset

-- Use 'local', designed for this
setLayoutTopLevelP :: (Monad m, Monoid w) => EP w m a -> EP w m a
setLayoutTopLevelP k = do
debugM $ "setLayoutTopLevelP entered"
oldAnchorOffset <- getLayoutOffsetP
modify (\a -> a { pMarkLayout = False
, pLHS = 0} )
r <- k
debugM $ "setLayoutTopLevelP:resetting"
setLayoutOffsetP oldAnchorOffset
return r

------------------------------------------------------------------------

getPosP :: (Monad m, Monoid w) => EP w m Pos
Expand Down

0 comments on commit e2d3da7

Please sign in to comment.