1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 00:12:29 +03:00

🔥 the unused Arbitrary instance over PrettyDiff.

This commit is contained in:
Rob Rix 2016-05-25 14:31:47 -04:00
parent 04e36c4dcb
commit 5fad7be0f5

View File

@ -221,10 +221,6 @@ toAlignBranchInputs elements = (sources, join . (`evalState` both 0 0) . mapM go
ranges = Source.actualLineRanges <$> (totalRange <$> sources) <*> sources ranges = Source.actualLineRanges <$> (totalRange <$> sources) <*> sources
bothContents = foldMap (modifyJoin (fromThese [] []) . fmap (:[]) . branchElementContents) bothContents = foldMap (modifyJoin (fromThese [] []) . fmap (:[]) . branchElementContents)
toPrettyDiff :: [BranchElement] -> PrettyDiff [(String, Range)]
toPrettyDiff elements = PrettyDiff sources (alignBranch id children ranges)
where (sources, children, ranges) = toAlignBranchInputs elements
keysOfAlignedChildren :: [Join These (Range, [(String, Range)])] -> [String] keysOfAlignedChildren :: [Join These (Range, [(String, Range)])] -> [String]
keysOfAlignedChildren lines = lines >>= these id id (++) . runJoin . fmap (fmap Prelude.fst . Prelude.snd) keysOfAlignedChildren lines = lines >>= these id id (++) . runJoin . fmap (fmap Prelude.fst . Prelude.snd)
@ -246,9 +242,6 @@ instance Arbitrary BranchElement where
(prefix, suffix) = ('(' : key, ")" :: String) (prefix, suffix) = ('(' : key, ")" :: String)
shrink (Margin contents) = Margin <$> crosswalk (shrinkList (const [])) contents shrink (Margin contents) = Margin <$> crosswalk (shrinkList (const [])) contents
instance Arbitrary (PrettyDiff [(String, Range)]) where
arbitrary = toPrettyDiff <$> listOf1 arbitrary
counts :: [Join These (Int, a)] -> Both Int counts :: [Join These (Int, a)] -> Both Int
counts numbered = fromMaybe 0 . getLast . mconcat . fmap Last <$> Join (unalign (runJoin . fmap Prelude.fst <$> numbered)) counts numbered = fromMaybe 0 . getLast . mconcat . fmap Last <$> Join (unalign (runJoin . fmap Prelude.fst <$> numbered))