1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 16:02:43 +03:00

Add a toPrettyDiff function to abstract the construction of pretty diffs away.

This commit is contained in:
Rob Rix 2016-05-24 13:04:10 -04:00
parent 24a732322c
commit e0e7f0fa4a

View File

@ -218,6 +218,11 @@ toAlignedChildren = join . (`evalState` both 0 0) . mapM go
put $ (+) <$> prev <*> modifyJoin (fromThese 0 0) (length <$> contents)
return []
toPrettyDiff :: [BranchElement] -> PrettyDiff [(String, Range)]
toPrettyDiff elements = PrettyDiff sources (alignBranch id children ranges)
where (sources, ranges) = toSourcesAndRanges elements
children = toAlignedChildren elements
instance Arbitrary BranchElement where
arbitrary = oneof [ key >>= \ key -> Child key <$> joinTheseOf (contents key)
, Margin <$> joinTheseOf margin ]