diff --git a/src/Alignment.hs b/src/Alignment.hs index 6f1db7084..3678a78c7 100644 --- a/src/Alignment.hs +++ b/src/Alignment.hs @@ -50,8 +50,11 @@ splitPatchByLines patch previous sources = case patch of (makeRow EmptyLine . fmap (Pure . SplitInsert) <$> lines, both (rangeAt $ fst previous) range) Delete term -> let (lines, range) = splitAbstractedTerm copoint unwrap (:<) (fst sources) term in (flip makeRow EmptyLine . fmap (Pure . SplitDelete) <$> lines, both range (rangeAt $ snd previous)) - Replace _ _ -> (zipWithDefaults makeRow (pure mempty) $ fmap (fmap (Pure . SplitReplace)) <$> lines, ranges) + Replace _ _ -> (zipWithDefaults makeRow (pure mempty) $ fmap (fmap (Pure . constructor patch)) <$> lines, ranges) where (lines, ranges) = transpose $ maybe . (,) [] . rangeAt <$> previous <*> (splitAbstractedTerm copoint unwrap (:<) <$> sources) <*> unPatch patch + constructor (Replace _ _) = SplitReplace + constructor (Insert _) = SplitInsert + constructor (Delete _) = SplitDelete -- | Split an `inTerm` (abstracted by two destructors) up into one `outTerm` (abstracted by a constructor) per line in `Source`. splitAbstractedTerm :: (inTerm -> Info) -> (inTerm -> Syntax leaf inTerm) -> (Info -> Syntax leaf outTerm -> outTerm) -> Source Char -> inTerm -> ([Line outTerm], Range)