on master help sign in
Group deprecation declarations with data types as well
825171amrkkrp
data/examples/declaration/warning/warning-single-line-out.hs+3
@@ -9,3 +9,6 @@ bar = 3
9
9
10{-# DEPRECATED baz "Baz is also deprecated" #-}
10{-# DEPRECATED baz "Baz is also deprecated" #-}
11baz = 5
11baz = 5
12+
13+data Number = Number Dobule
14+{-# DEPRECATED Number "Use Scientific instead." #-}
data/examples/declaration/warning/warning-single-line.hs+2
@@ -11,3 +11,5 @@ bar = 3
11{-# DEPRECATED baz "Baz is also deprecated" #-}
11{-# DEPRECATED baz "Baz is also deprecated" #-}
12baz = 5
12baz = 5
13
13
14+data Number = Number Dobule
15+{-# DEPRECATED Number "Use Scientific instead." #-}
src/Ormolu/Printer/Meat/Declaration.hs+8−1
@@ -12,6 +12,7 @@ where
12
12
13import Control.Monad (forM_)
13import Control.Monad (forM_)
14import GHC
14import GHC
15+import OccName (occNameFS)
15import Ormolu.Printer.Combinators
16import Ormolu.Printer.Combinators
16import Ormolu.Printer.Meat.Common
17import Ormolu.Printer.Meat.Common
17import Ormolu.Printer.Meat.Declaration.Annotation
18import Ormolu.Printer.Meat.Declaration.Annotation
@@ -30,6 +31,7 @@ import Ormolu.Printer.Meat.Declaration.Value
30import Ormolu.Printer.Meat.Declaration.Warning
31import Ormolu.Printer.Meat.Declaration.Warning
31import Ormolu.Printer.Meat.Type
32import Ormolu.Printer.Meat.Type
32import Ormolu.Utils
33import Ormolu.Utils
34+import RdrName (rdrNameOcc)
33
35
34p_hsDecls :: FamilyStyle -> [LHsDecl GhcPs] -> R ()
36p_hsDecls :: FamilyStyle -> [LHsDecl GhcPs] -> R ()
35p_hsDecls style decls =
37p_hsDecls style decls =
@@ -105,6 +107,9 @@ separatedDecls
105separatedDecls (TypeSignature n) (FunctionBody n') = n /= n'
107separatedDecls (TypeSignature n) (FunctionBody n') = n /= n'
106separatedDecls x (FunctionBody n) | Just n' <- isPragma x = n /= n'
108separatedDecls x (FunctionBody n) | Just n' <- isPragma x = n /= n'
107separatedDecls (FunctionBody n) x | Just n' <- isPragma x = n /= n'
109separatedDecls (FunctionBody n) x | Just n' <- isPragma x = n /= n'
110+separatedDecls x (DataDeclaration n) | Just n' <- isPragma x = n /= n'
111+separatedDecls (DataDeclaration n) x | Just n' <- isPragma x =
112+ let f = occNameFS . rdrNameOcc in f n /= f n'
108separatedDecls x y | Just n <- isPragma x, Just n' <- isPragma y = n /= n'
113separatedDecls x y | Just n <- isPragma x, Just n' <- isPragma y = n /= n'
109separatedDecls x (TypeSignature n') | Just n <- isPragma x = n /= n'
114separatedDecls x (TypeSignature n') | Just n <- isPragma x = n /= n'
110separatedDecls (PatternSignature n) (Pattern n') = n /= n'
115separatedDecls (PatternSignature n) (Pattern n') = n /= n'
@@ -131,7 +136,8 @@ pattern TypeSignature
131 , AnnValuePragma
136 , AnnValuePragma
132 , PatternSignature
137 , PatternSignature
133 , Pattern
138 , Pattern
134− , WarningPragma :: RdrName -> HsDecl GhcPs
139+ , WarningPragma
140+ , DataDeclaration :: RdrName -> HsDecl GhcPs
135pattern TypeSignature n <- (sigRdrName -> Just n)
141pattern TypeSignature n <- (sigRdrName -> Just n)
136pattern FunctionBody n <- ValD NoExt (FunBind NoExt (L _ n) _ _ _)
142pattern FunctionBody n <- ValD NoExt (FunBind NoExt (L _ n) _ _ _)
137pattern InlinePragma n <- SigD NoExt (InlineSig NoExt (L _ n) _)
143pattern InlinePragma n <- SigD NoExt (InlineSig NoExt (L _ n) _)
@@ -142,6 +148,7 @@ pattern AnnValuePragma n <- AnnD NoExt (HsAnnotation NoExt _ (ValueAnnProvenance
142pattern PatternSignature n <- SigD NoExt (PatSynSig NoExt ((L _ n):_) _)
148pattern PatternSignature n <- SigD NoExt (PatSynSig NoExt ((L _ n):_) _)
143pattern Pattern n <- ValD NoExt (PatSynBind NoExt (PSB _ (L _ n) _ _ _))
149pattern Pattern n <- ValD NoExt (PatSynBind NoExt (PSB _ (L _ n) _ _ _))
144pattern WarningPragma n <- WarningD NoExt (Warnings NoExt _ [(L _ (Warning NoExt [(L _ n)] _))])
150pattern WarningPragma n <- WarningD NoExt (Warnings NoExt _ [(L _ (Warning NoExt [(L _ n)] _))])
151+pattern DataDeclaration n <- TyClD NoExt (DataDecl NoExt (L _ n) _ _ _)
145
152
146sigRdrName :: HsDecl GhcPs -> Maybe RdrName
153sigRdrName :: HsDecl GhcPs -> Maybe RdrName
147sigRdrName (SigD NoExt (TypeSig NoExt ((L _ n):_) _)) = Just n
154sigRdrName (SigD NoExt (TypeSig NoExt ((L _ n):_) _)) = Just n