1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +03:00

Generalize termToDiffInfo over records.

This commit is contained in:
Rob Rix 2016-07-14 14:25:27 -04:00
parent fa44ef74d8
commit 13d2dfc24f

View File

@ -145,7 +145,7 @@ diffSummary = cata $ \case
(Pure (Delete term)) -> (\info -> DiffSummary (Delete info) []) <$> termToDiffInfo term (Pure (Delete term)) -> (\info -> DiffSummary (Delete info) []) <$> termToDiffInfo term
(Pure (Replace t1 t2)) -> (\(info1, info2) -> DiffSummary (Replace info1 info2) []) <$> zip (termToDiffInfo t1) (termToDiffInfo t2) (Pure (Replace t1 t2)) -> (\(info1, info2) -> DiffSummary (Replace info1 info2) []) <$> zip (termToDiffInfo t1) (termToDiffInfo t2)
termToDiffInfo :: HasCategory leaf => Term leaf Info -> [DiffInfo] termToDiffInfo :: (HasCategory leaf, HasField fields Category) => Term leaf (Record fields) -> [DiffInfo]
termToDiffInfo term = case runCofree term of termToDiffInfo term = case runCofree term of
(_ :< Leaf _) -> [ DiffInfo (toCategoryName term) (toTermName term) ] (_ :< Leaf _) -> [ DiffInfo (toCategoryName term) (toTermName term) ]
(_ :< Indexed children) -> join $ termToDiffInfo <$> children (_ :< Indexed children) -> join $ termToDiffInfo <$> children