From 28a06eaec46862bc282ced693592d1b1fd230dc2 Mon Sep 17 00:00:00 2001 From: joshvera Date: Wed, 29 Jun 2016 11:11:50 -0400 Subject: [PATCH] Diff objects --- src/Interpreter.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Interpreter.hs b/src/Interpreter.hs index aaa8c16b0..2d96f9f6e 100644 --- a/src/Interpreter.hs +++ b/src/Interpreter.hs @@ -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