From 9ecf668fbcbb29f826049ca42df4a7dad0f5c710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B5=D0=B2=20=D0=9A=D0=B8?= =?UTF-8?q?=D1=80=D0=B8=D0=BB=D0=BB?= Date: Thu, 4 Nov 2021 18:41:18 +0400 Subject: [PATCH] Add explicit strategies to deriving clauses Problem: The `deriving ($classes...)` is becoming obsolete. Solution: Replace with `deriving $strat ($classes...)`; make old deriving a warning. --- links-tests/Test/Xrefcheck/FtpLinks.hs | 2 +- package.yaml | 1 + src/Xrefcheck/Core.hs | 18 +++++++++--------- src/Xrefcheck/Orphans.hs | 2 +- src/Xrefcheck/Progress.hs | 2 +- src/Xrefcheck/Scanners/Markdown.hs | 2 +- src/Xrefcheck/Verify.hs | 8 ++++---- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/links-tests/Test/Xrefcheck/FtpLinks.hs b/links-tests/Test/Xrefcheck/FtpLinks.hs index f93eb30..c6bed32 100644 --- a/links-tests/Test/Xrefcheck/FtpLinks.hs +++ b/links-tests/Test/Xrefcheck/FtpLinks.hs @@ -29,7 +29,7 @@ ftpOptions = -- | Option specifying FTP host. newtype FtpHostOpt = FtpHostOpt Text - deriving (Show, Eq) + deriving stock (Show, Eq) instance IsOption FtpHostOpt where defaultValue = FtpHostOpt "ftp://localhost" diff --git a/package.yaml b/package.yaml index 85942fe..700653e 100644 --- a/package.yaml +++ b/package.yaml @@ -55,6 +55,7 @@ ghc-options: - -Wall - -Wincomplete-record-updates - -Wincomplete-uni-patterns + - -Wmissing-deriving-strategies dependencies: - aeson diff --git a/src/Xrefcheck/Core.hs b/src/Xrefcheck/Core.hs index 32d0cfc..0ef754d 100644 --- a/src/Xrefcheck/Core.hs +++ b/src/Xrefcheck/Core.hs @@ -40,7 +40,7 @@ import Data.DList qualified as DList data Flavor = GitHub | GitLab - deriving (Show) + deriving stock (Show) allFlavors :: [Flavor] allFlavors = [GitHub, GitLab] @@ -61,7 +61,7 @@ instance FromJSON Flavor where -- We keep this in text because scanners for different formats use different -- representation of this thing, and it actually appears in reports only. newtype Position = Position (Maybe Text) - deriving (Show, Eq, Generic) + deriving stock (Show, Eq, Generic) instance Buildable Position where build (Position pos) = case pos of @@ -77,7 +77,7 @@ data Reference = Reference , rAnchor :: Maybe Text -- ^ Section or custom anchor tag. , rPos :: Position - } deriving (Show, Generic) + } deriving stock (Show, Generic) -- | Context of anchor. data AnchorType @@ -87,14 +87,14 @@ data AnchorType -- ^ They can be set up manually | BiblioAnchor -- ^ Id of entry in bibliography - deriving (Show, Eq, Generic) + deriving stock (Show, Eq, Generic) -- | A referable anchor. data Anchor = Anchor { aType :: AnchorType , aName :: Text , aPos :: Position - } deriving (Show, Eq, Generic) + } deriving stock (Show, Eq, Generic) data FileInfoDiff = FileInfoDiff { _fidReferences :: DList Reference @@ -116,14 +116,14 @@ instance Monoid FileInfoDiff where data FileInfo = FileInfo { _fiReferences :: [Reference] , _fiAnchors :: [Anchor] - } deriving (Show, Generic) + } deriving stock (Show, Generic) makeLenses ''FileInfo instance Default FileInfo where def = diffToFileInfo mempty newtype RepoInfo = RepoInfo (Map FilePath FileInfo) - deriving (Show) + deriving stock (Show) ----------------------------------------------------------- -- Instances @@ -189,7 +189,7 @@ data LocationType -- ^ Reference to a file at outer site | OtherLoc -- ^ Entry not to be processed (e.g. "mailto:e-mail") - deriving (Show) + deriving stock (Show) instance Buildable LocationType where build = \case @@ -303,7 +303,7 @@ canonizeLocalRef ref = data VerifyProgress = VerifyProgress { vrLocal :: !(Progress Int) , vrExternal :: !(Progress Int) - } deriving (Show) + } deriving stock (Show) initVerifyProgress :: [Reference] -> VerifyProgress initVerifyProgress references = VerifyProgress diff --git a/src/Xrefcheck/Orphans.hs b/src/Xrefcheck/Orphans.hs index 8936f7a..ba1f3cc 100644 --- a/src/Xrefcheck/Orphans.hs +++ b/src/Xrefcheck/Orphans.hs @@ -44,4 +44,4 @@ instance Buildable FTPException where build (UnsuccessfulException e) = build e build (BogusResponseFormatException e) = build e -deriving instance Eq FTPException +deriving stock instance Eq FTPException diff --git a/src/Xrefcheck/Progress.hs b/src/Xrefcheck/Progress.hs index 0121a77..70a3bad 100644 --- a/src/Xrefcheck/Progress.hs +++ b/src/Xrefcheck/Progress.hs @@ -36,7 +36,7 @@ data Progress a = Progress -- ^ Overall amount of work. , pErrors :: !a -- ^ How many of the completed work finished with an error. - } deriving (Show) + } deriving stock (Show) -- | Initialise null progress. initProgress :: Num a => a -> Progress a diff --git a/src/Xrefcheck/Scanners/Markdown.hs b/src/Xrefcheck/Scanners/Markdown.hs index 6822250..9dbad32 100644 --- a/src/Xrefcheck/Scanners/Markdown.hs +++ b/src/Xrefcheck/Scanners/Markdown.hs @@ -73,7 +73,7 @@ data IgnoreMode | Paragraph | File | None - deriving Eq + deriving stock (Eq) -- | A fold over a `Node`. cataNode :: (Maybe PosInfo -> NodeType -> [c] -> c) -> Node -> c diff --git a/src/Xrefcheck/Verify.hs b/src/Xrefcheck/Verify.hs index c54f84a..f3be215 100644 --- a/src/Xrefcheck/Verify.hs +++ b/src/Xrefcheck/Verify.hs @@ -64,10 +64,10 @@ import Xrefcheck.System ----------------------------------------------------------- newtype VerifyResult e = VerifyResult [e] - deriving (Show, Eq, Functor) + deriving newtype (Show, Eq, Functor) -deriving instance Semigroup (VerifyResult e) -deriving instance Monoid (VerifyResult e) +deriving newtype instance Semigroup (VerifyResult e) +deriving newtype instance Monoid (VerifyResult e) instance Buildable e => Buildable (VerifyResult e) where build vr = case verifyErrors vr of @@ -114,7 +114,7 @@ data VerifyError | ExternalFtpException FTPException | FtpEntryDoesNotExist FilePath | ExternalResourceSomeError Text - deriving (Show, Eq) + deriving stock (Show, Eq) instance Buildable VerifyError where build = \case