mirror of
https://github.com/github/semantic.git
synced 2024-12-23 23:11:50 +03:00
Diff objects
This commit is contained in:
parent
4d2716c5a4
commit
28a06eaec4
@ -2,11 +2,12 @@ module Interpreter (Comparable, DiffConstructor, diffTerms) where
|
||||
|
||||
import Algorithm
|
||||
import Data.Functor.Foldable
|
||||
import Data.Functor.Both
|
||||
import Data.Functor.Both hiding (fst, snd)
|
||||
import qualified Data.OrderedMap as Map
|
||||
import qualified Data.List as List
|
||||
import Data.List ((\\))
|
||||
import Data.OrderedMap ((!))
|
||||
import Control.Arrow ((***))
|
||||
import Diff
|
||||
import Operation
|
||||
import Patch
|
||||
@ -71,6 +72,7 @@ run construct comparable cost algorithm = case runFree algorithm of
|
||||
recur (Operator a') (Operator b') = annotate $ Operator (zipWith diffTerms' a' b')
|
||||
recur (Switch a' as') (Switch b' bs') = annotate $ Switch (diffTerms' a' b') (alignWith (these (pure . Delete) (pure . Insert) diffTerms') as' bs')
|
||||
recur (Case a' as') (Case b' bs') = annotate $ Case (diffTerms' a' b') (diffTerms' as' bs')
|
||||
recur (Object as') (Object bs') = annotate $ Object (zipWith (\a b -> (diffTerms' (fst a) *** diffTerms' (snd a)) b) as' bs')
|
||||
recur (Leaf _) (Leaf _) = pure $ Replace (cofree (annotation1 :< a)) (cofree (annotation2 :< b))
|
||||
recur _ _ = error $ "Unimplemented Interpreter.run term comparison between a: " <> show a <> "\nb: " <> show b
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user