1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 06:41:45 +03:00

Remove the constructor parameter from alignTermBy and rename it.

This commit is contained in:
Rob Rix 2016-03-18 14:58:01 -04:00
parent 30e1da5a12
commit a11bc809df

View File

@ -114,14 +114,14 @@ newtype Fix f = Fix { unFix :: f (Fix f) }
type AlignedDiff leaf = Cofree (Aligned (Syntax leaf)) (Join These Info)
alignPatch :: Both (Source Char) -> Patch (Term leaf Info) -> AlignedDiff leaf
alignPatch sources (Insert term) = hylo (alignTermBy sources AlignThis) unCofree (Join . This <$> term)
alignPatch sources (Delete term) = hylo (alignTermBy sources AlignThat) unCofree (Join . That <$> term)
alignPatch sources (Replace term1 term2) = let Join (This info1) :< AlignThis a = hylo (alignTermBy sources AlignThis) unCofree (Join . This <$> term1)
Join (That info2) :< AlignThat b = hylo (alignTermBy sources AlignThat) unCofree (Join . That <$> term2) in
alignPatch sources (Insert term) = hylo (alignTerm sources) unCofree (Join . This <$> term)
alignPatch sources (Delete term) = hylo (alignTerm sources) unCofree (Join . That <$> term)
alignPatch sources (Replace term1 term2) = let Join (This info1) :< AlignThis a = hylo (alignTerm sources) unCofree (Join . This <$> term1)
Join (That info2) :< AlignThat b = hylo (alignTerm sources) unCofree (Join . That <$> term2) in
Join (These info1 info2) :< AlignThese a b
alignTermBy :: Both (Source Char) -> (forall r. [Syntax leaf r] -> Aligned (Syntax leaf) r) -> Join These Info -> Syntax leaf (AlignedDiff leaf) -> AlignedDiff leaf
alignTermBy sources constructor infos syntax = infos :< Aligned (alignSyntax sources (characterRange <$> infos) syntax)
alignTerm :: Both (Source Char) -> Join These Info -> Syntax leaf (AlignedDiff leaf) -> AlignedDiff leaf
alignTerm sources infos syntax = infos :< Aligned (alignSyntax sources (characterRange <$> infos) syntax)
alignSyntax :: Both (Source Char) -> Join These Range -> Syntax leaf (AlignedDiff leaf) -> Join These [Syntax leaf (AlignedDiff leaf)]
alignSyntax sources ranges (Leaf s) = (Leaf s <$) <$> lineRanges