From 06dd79dc767ba2fe702926fab95d6606ba7740fa Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 4 Apr 2016 17:26:40 -0400 Subject: [PATCH] Align patches. --- src/Alignment.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Alignment.hs b/src/Alignment.hs index db8a2d17e..c7cda7b0e 100644 --- a/src/Alignment.hs +++ b/src/Alignment.hs @@ -114,11 +114,11 @@ type Row a = Both (Line a) type AlignedDiff leaf = [Join These (SplitDiff leaf Info)] alignPatch :: Both (Source Char) -> Patch (Term leaf Info) -> AlignedDiff leaf -alignPatch sources (Delete term) = hylo (alignSyntax (Join . This . runIdentity) (Identity $ fst sources)) unCofree (Identity <$> term) -alignPatch sources (Insert term) = hylo (alignSyntax (Join . That . runIdentity) (Identity $ snd sources)) unCofree (Identity <$> term) -alignPatch _ _ = [] --- alignPatch sources (Replace term1 term2) = alignWith Join (hylo (alignTerm sources) unCofree term1) --- (hylo (alignTerm sources) unCofree term2) +alignPatch sources (Delete term) = hylo (alignSyntax (Join . This . runIdentity) (Identity (fst sources))) unCofree (Identity <$> term) +alignPatch sources (Insert term) = hylo (alignSyntax (Join . That . runIdentity) (Identity (snd sources))) unCofree (Identity <$> term) +alignPatch sources (Replace term1 term2) = alignWith (fmap (these id id const . runJoin) . Join) + (hylo (alignSyntax (Join . This . runIdentity) (Identity (fst sources))) unCofree (Identity <$> term1)) + (hylo (alignSyntax (Join . That . runIdentity) (Identity (snd sources))) unCofree (Identity <$> term2)) alignDiff :: Both (Source Char) -> Diff leaf Info -> AlignedDiff leaf alignDiff sources diff = iter (uncurry (alignSyntax (runBothWith ((Join .) . These)) sources) . (annotation &&& syntax)) (alignPatch sources <$> diff)