1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 07:25:44 +03:00

Generalize diffSummary' to extensible record annotations.

This commit is contained in:
Rob Rix 2016-07-14 15:50:38 -04:00
parent ea6ff00a7a
commit 0bbe856d3d

View File

@ -69,7 +69,7 @@ instance Show (DiffSummary DiffInfo) where
diffSummary :: HasCategory leaf => Diff leaf Info -> [DiffSummary DiffInfo]
diffSummary = cata diffSummary' where
diffSummary' :: HasCategory leaf => Base (Diff leaf Info) [DiffSummary DiffInfo] -> [DiffSummary DiffInfo]
diffSummary' :: (HasCategory leaf, HasField fields Category) => Base (Diff leaf (Record fields)) [DiffSummary DiffInfo] -> [DiffSummary DiffInfo]
diffSummary' (Free (_ :< Leaf _)) = [] -- Skip leaves since they don't have any changes
diffSummary' (Free (infos :< Indexed children)) = prependSummary (DiffInfo (toCategoryName . category $ snd infos) Nothing) <$> join children
diffSummary' (Free (infos :< Fixed children)) = prependSummary (DiffInfo (toCategoryName . category $ snd infos) Nothing) <$> join children