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

Remove DeclSig #783

Merged
merged 2 commits into from
Oct 27, 2023
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
64 changes: 24 additions & 40 deletions src/HIndent/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ instance Pretty (HsDecl GhcPs) where
pretty' (InstD _ inst) = pretty inst
pretty' (DerivD _ x) = pretty x
pretty' (ValD _ bind) = pretty bind
pretty' (SigD _ s) = pretty $ DeclSig s
pretty' (SigD _ s) = pretty s
pretty' (KindSigD _ x) = pretty x
pretty' (DefD _ x) = pretty x
pretty' (ForD _ x) = pretty x
Expand Down Expand Up @@ -402,18 +402,21 @@ instance Pretty (Sig GhcPs) where
string " ::"
horizontal <-|> vertical
where
horizontal = space >> pretty (hswc_body params)
horizontal = do
space
pretty $ HsSigTypeInsideDeclSig <$> hswc_body params
vertical = do
headLen <- printerLength printFunName
indentSpaces <- getIndentSpaces
if headLen < indentSpaces
then space
else newline
indentedBlock
$ indentedWithSpace 3
$ pretty
$ HsSigTypeInsideVerticalFuncSig <$> hswc_body params
printFunName = pretty $ head funName
then space |=> pretty (HsSigTypeInsideDeclSig <$> hswc_body params)
else do
newline
indentedBlock
$ indentedWithSpace 3
$ pretty
$ HsSigTypeInsideDeclSig <$> hswc_body params
printFunName = hCommaSep $ fmap pretty funName
pretty' (PatSynSig _ names sig) =
spaced
[string "pattern", hCommaSep $ fmap pretty names, string "::", pretty sig]
Expand Down Expand Up @@ -467,18 +470,21 @@ instance Pretty (Sig GhcPs) where
string " ::"
horizontal <-|> vertical
where
horizontal = space >> pretty (hswc_body params)
horizontal = do
space
pretty $ HsSigTypeInsideDeclSig <$> hswc_body params
vertical = do
headLen <- printerLength printFunName
indentSpaces <- getIndentSpaces
if headLen < indentSpaces
then space
else newline
indentedBlock
$ indentedWithSpace 3
$ pretty
$ HsSigTypeInsideVerticalFuncSig <$> hswc_body params
printFunName = pretty $ head funName
then space |=> pretty (HsSigTypeInsideDeclSig <$> hswc_body params)
else do
newline
indentedBlock
$ indentedWithSpace 3
$ pretty
$ HsSigTypeInsideDeclSig <$> hswc_body params
printFunName = hCommaSep $ fmap pretty funName
pretty' (PatSynSig _ names sig) =
spaced
[string "pattern", hCommaSep $ fmap pretty names, string "::", pretty sig]
Expand Down Expand Up @@ -527,28 +533,6 @@ instance Pretty (Sig GhcPs) where
, string "#-}"
]
#endif
instance Pretty DeclSig where
pretty' (DeclSig (TypeSig _ funName params)) = do
printFunName
string " ::"
horizontal <-|> vertical
where
horizontal = do
space
pretty $ HsSigTypeInsideDeclSig <$> hswc_body params
vertical = do
headLen <- printerLength printFunName
indentSpaces <- getIndentSpaces
if headLen < indentSpaces
then space |=> pretty (HsSigTypeInsideDeclSig <$> hswc_body params)
else do
newline
indentedBlock
$ indentedWithSpace 3
$ pretty
$ HsSigTypeInsideDeclSig <$> hswc_body params
printFunName = hCommaSep $ fmap pretty funName
pretty' (DeclSig x) = pretty x
#if MIN_VERSION_ghc_lib_parser(9,6,1)
instance Pretty (HsDataDefn GhcPs) where
pretty' HsDataDefn {..} =
Expand Down Expand Up @@ -1609,7 +1593,7 @@ instance Pretty (HsBracket GhcPs) where
pretty' (TExpBr _ x) = typedBrackets $ pretty x
#endif
instance Pretty SigBindFamily where
pretty' (Sig x) = pretty $ DeclSig x
pretty' (Sig x) = pretty x
pretty' (Bind x) = pretty x
pretty' (TypeFamily x) = pretty x
pretty' (TyFamInst x) = pretty x
Expand Down
3 changes: 0 additions & 3 deletions src/HIndent/Pretty/NodeComments.hs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ instance CommentExtraction (Sig GhcPs) where
nodeComments (SCCFunSig x _ _ _) = nodeComments x
nodeComments (CompleteMatchSig x _ _ _) = nodeComments x
#endif
instance CommentExtraction DeclSig where
nodeComments (DeclSig x) = nodeComments x

instance CommentExtraction (HsDataDefn GhcPs) where
nodeComments HsDataDefn {} = emptyNodeComments

Expand Down
5 changes: 0 additions & 5 deletions src/HIndent/Pretty/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ module HIndent.Pretty.Types
, pattern FamEqnInsideClassInst
, StmtLRInsideVerticalList(..)
, ParStmtBlockInsideVerticalList(..)
, DeclSig(..)
, TopLevelTyFamInstDecl(..)
, Context(..)
, HorizontalContext(..)
Expand Down Expand Up @@ -204,10 +203,6 @@ newtype StmtLRInsideVerticalList =
newtype ParStmtBlockInsideVerticalList =
ParStmtBlockInsideVerticalList (ParStmtBlock GhcPs GhcPs)

-- | A top-level function signature.
newtype DeclSig =
DeclSig (Sig GhcPs)

-- | A top-level type family instance declaration.
newtype TopLevelTyFamInstDecl =
TopLevelTyFamInstDecl (TyFamInstDecl GhcPs)
Expand Down