From e0e7f0fa4a487758b2d51f9e8b0ab7640d1d49bb Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 24 May 2016 13:04:10 -0400 Subject: [PATCH] Add a toPrettyDiff function to abstract the construction of pretty diffs away. --- test/AlignmentSpec.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/AlignmentSpec.hs b/test/AlignmentSpec.hs index 981647b86..114bae486 100644 --- a/test/AlignmentSpec.hs +++ b/test/AlignmentSpec.hs @@ -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 ]