Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Convert empty instances to derive anyclass
  • Loading branch information
Heimdell committed Nov 9, 2021
commit 317e3a6b4be8296b80f16cd93cd710d05e856972
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ default-extensions:
- ConstraintKinds
- DataKinds
- DefaultSignatures
- DeriveAnyClass
- DeriveDataTypeable
- DeriveGeneric
- DerivingStrategies
Expand Down
20 changes: 11 additions & 9 deletions src/Xrefcheck/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ instance FromJSON Flavor where
-- representation of this thing, and it actually appears in reports only.
newtype Position = Position (Maybe Text)
deriving stock (Show, Eq, Generic)
deriving anyclass NFData

instance Buildable Position where
build (Position pos) = case pos of
Expand All @@ -77,7 +78,9 @@ data Reference = Reference
, rAnchor :: Maybe Text
-- ^ Section or custom anchor tag.
, rPos :: Position
} deriving stock (Show, Generic)
}
deriving stock (Show, Generic)
deriving anyclass NFData

-- | Context of anchor.
data AnchorType
Expand All @@ -88,13 +91,16 @@ data AnchorType
| BiblioAnchor
-- ^ Id of entry in bibliography
deriving stock (Show, Eq, Generic)
deriving anyclass NFData

-- | A referable anchor.
data Anchor = Anchor
{ aType :: AnchorType
, aName :: Text
, aPos :: Position
} deriving stock (Show, Eq, Generic)
}
deriving stock (Show, Eq, Generic)
deriving anyclass NFData

data FileInfoDiff = FileInfoDiff
{ _fidReferences :: DList Reference
Expand All @@ -116,7 +122,9 @@ instance Monoid FileInfoDiff where
data FileInfo = FileInfo
{ _fiReferences :: [Reference]
, _fiAnchors :: [Anchor]
} deriving stock (Show, Generic)
}
deriving stock (Show, Generic)
deriving anyclass NFData
makeLenses ''FileInfo

instance Default FileInfo where
Expand All @@ -129,12 +137,6 @@ newtype RepoInfo = RepoInfo (Map FilePath FileInfo)
-- Instances
-----------------------------------------------------------

instance NFData Position
instance NFData Reference
instance NFData AnchorType
instance NFData Anchor
instance NFData FileInfo

instance Buildable Reference where
build Reference{..} =
nameF ("reference " +| paren (build loc) |+ " " +| rPos |+ "") $
Expand Down