1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 01:42:43 +03:00

Use the factored-out annotations.

This commit is contained in:
Rob Rix 2015-11-27 11:46:25 -05:00
parent f4c73cb3f7
commit 95750ea60d

View File

@ -34,9 +34,9 @@ run :: (Eq a, Eq annotation) => Comparable a annotation -> Algorithm a annotatio
run _ (Pure diff) = Just diff
run comparable (Free (Recursive (annotation1 :< a) (annotation2 :< b) f)) = run comparable . f $ recur a b where
recur (Indexed a') (Indexed b') | length a' == length b' = Free . Annotated (annotation1, annotation2) . Indexed $ zipWith (interpret comparable) a' b'
recur (Fixed a') (Fixed b') | length a' == length b' = Free . Annotated (annotation1, annotation2) . Fixed $ zipWith (interpret comparable) a' b'
recur (Keyed a') (Keyed b') | keys a' == keys b' = Free . Annotated (annotation1, annotation2) . Keyed . fromList . fmap repack $ keys b'
recur (Indexed a') (Indexed b') | length a' == length b' = annotate . Indexed $ zipWith (interpret comparable) a' b'
recur (Fixed a') (Fixed b') | length a' == length b' = annotate . Fixed $ zipWith (interpret comparable) a' b'
recur (Keyed a') (Keyed b') | keys a' == keys b' = annotate . Keyed . fromList . fmap repack $ keys b'
where
repack key = (key, interpretInBoth key a' b')
interpretInBoth key a' b' = maybeInterpret (Data.Map.lookup key a') (Data.Map.lookup key b')