diff --git a/hindent.cabal b/hindent.cabal index 286ad33ec..6bb85a939 100644 --- a/hindent.cabal +++ b/hindent.cabal @@ -68,6 +68,7 @@ library HIndent.Ast.Declaration.Signature.Fixity.Associativity HIndent.Ast.Declaration.Signature.Inline.Phase HIndent.Ast.Declaration.Signature.Inline.Spec + HIndent.Ast.Declaration.Signature.StandaloneKind HIndent.Ast.Declaration.StandAloneDeriving HIndent.Ast.Declaration.TypeSynonym HIndent.Ast.Declaration.TypeSynonym.Lhs diff --git a/src/HIndent/Ast/Declaration.hs b/src/HIndent/Ast/Declaration.hs index 5222c45b1..964b195b4 100644 --- a/src/HIndent/Ast/Declaration.hs +++ b/src/HIndent/Ast/Declaration.hs @@ -17,6 +17,7 @@ import HIndent.Ast.Declaration.Instance.Class import HIndent.Ast.Declaration.Instance.Family.Data import HIndent.Ast.Declaration.Instance.Family.Type import HIndent.Ast.Declaration.Signature +import HIndent.Ast.Declaration.Signature.StandaloneKind import HIndent.Ast.Declaration.StandAloneDeriving import HIndent.Ast.Declaration.TypeSynonym import HIndent.Ast.NodeComments @@ -36,7 +37,7 @@ data Declaration | StandAloneDeriving StandAloneDeriving | Bind Bind | Signature Signature - | KindSigDecl (GHC.StandaloneKindSig GHC.GhcPs) + | StandaloneKindSignature StandaloneKind | DefDecl (GHC.DefaultDecl GHC.GhcPs) | ForDecl (GHC.ForeignDecl GHC.GhcPs) | WarningDecl (GHC.WarnDecls GHC.GhcPs) @@ -57,7 +58,7 @@ instance CommentExtraction Declaration where nodeComments StandAloneDeriving {} = NodeComments [] [] [] nodeComments Bind {} = NodeComments [] [] [] nodeComments Signature {} = NodeComments [] [] [] - nodeComments KindSigDecl {} = NodeComments [] [] [] + nodeComments StandaloneKindSignature {} = NodeComments [] [] [] nodeComments DefDecl {} = NodeComments [] [] [] nodeComments ForDecl {} = NodeComments [] [] [] nodeComments WarningDecl {} = NodeComments [] [] [] @@ -78,7 +79,7 @@ instance Pretty Declaration where pretty' (StandAloneDeriving x) = pretty x pretty' (Bind x) = pretty x pretty' (Signature x) = pretty x - pretty' (KindSigDecl x) = pretty x + pretty' (StandaloneKindSignature x) = pretty x pretty' (DefDecl x) = pretty x pretty' (ForDecl x) = pretty x pretty' (WarningDecl x) = pretty x @@ -105,7 +106,7 @@ mkDeclaration (GHC.InstD _ x@GHC.TyFamInstD {}) = mkDeclaration (GHC.DerivD _ x) = StandAloneDeriving $ mkStandAloneDeriving x mkDeclaration (GHC.ValD _ x) = Bind $ mkBind x mkDeclaration (GHC.SigD _ x) = Signature $ mkSignature x -mkDeclaration (GHC.KindSigD _ x) = KindSigDecl x +mkDeclaration (GHC.KindSigD _ x) = StandaloneKindSignature $ mkStandaloneKind x mkDeclaration (GHC.DefD _ x) = DefDecl x mkDeclaration (GHC.ForD _ x) = ForDecl x mkDeclaration (GHC.WarningD _ x) = WarningDecl x diff --git a/src/HIndent/Ast/Declaration/Signature/StandaloneKind.hs b/src/HIndent/Ast/Declaration/Signature/StandaloneKind.hs new file mode 100644 index 000000000..9b420ea2c --- /dev/null +++ b/src/HIndent/Ast/Declaration/Signature/StandaloneKind.hs @@ -0,0 +1,27 @@ +{-# LANGUAGE RecordWildCards #-} + +module HIndent.Ast.Declaration.Signature.StandaloneKind + ( StandaloneKind + , mkStandaloneKind + ) where + +import qualified GHC.Hs as GHC +import HIndent.Ast.NodeComments +import {-# SOURCE #-} HIndent.Pretty +import HIndent.Pretty.Combinators +import HIndent.Pretty.NodeComments + +data StandaloneKind = StandaloneKind + { name :: GHC.LIdP GHC.GhcPs + , kind :: GHC.LHsSigType GHC.GhcPs + } + +instance CommentExtraction StandaloneKind where + nodeComments StandaloneKind {} = NodeComments [] [] [] + +instance Pretty StandaloneKind where + pretty' StandaloneKind {..} = + spaced [string "type", pretty name, string "::", pretty kind] + +mkStandaloneKind :: GHC.StandaloneKindSig GHC.GhcPs -> StandaloneKind +mkStandaloneKind (GHC.StandaloneKindSig _ name kind) = StandaloneKind {..} diff --git a/src/HIndent/Pretty.hs b/src/HIndent/Pretty.hs index 58c940d71..e9e6a4968 100644 --- a/src/HIndent/Pretty.hs +++ b/src/HIndent/Pretty.hs @@ -1545,10 +1545,6 @@ instance Pretty (GHC.GenLocated GHC.SrcSpanAnnA (GHC.HsType GHC.GhcPs))) where pretty' GHC.HsWC {..} = pretty hswc_body -instance Pretty (GHC.StandaloneKindSig GHC.GhcPs) where - pretty' (GHC.StandaloneKindSig _ name kind) = - spaced [string "type", pretty name, string "::", pretty kind] - instance Pretty (GHC.DefaultDecl GHC.GhcPs) where pretty' (GHC.DefaultDecl _ xs) = spaced [string "default", hTuple $ fmap pretty xs] diff --git a/src/HIndent/Pretty.hs-boot b/src/HIndent/Pretty.hs-boot index 6308809f5..23200edea 100644 --- a/src/HIndent/Pretty.hs-boot +++ b/src/HIndent/Pretty.hs-boot @@ -77,8 +77,6 @@ instance Pretty (GHC.HsPatSynDir GHC.GhcPs) instance Pretty PatInsidePatDecl -instance Pretty (GHC.StandaloneKindSig GHC.GhcPs) - instance Pretty (GHC.DefaultDecl GHc.GhcPs) instance Pretty (GHC.ForeignDecl GHC.GhcPs)