diff --git a/src/Diffing/Interpreter.hs b/src/Diffing/Interpreter.hs index 0359952da..f16a07923 100644 --- a/src/Diffing/Interpreter.hs +++ b/src/Diffing/Interpreter.hs @@ -1,6 +1,7 @@ -{-# LANGUAGE FunctionalDependencies, GeneralizedNewtypeDeriving, TypeOperators, UndecidableInstances #-} +{-# LANGUAGE FunctionalDependencies, GeneralizedNewtypeDeriving, TypeFamilyDependencies, TypeOperators, UndecidableInstances #-} module Diffing.Interpreter ( diffTerms +, HasDiffFor(..) , DiffTerms(..) , stripDiff ) where @@ -29,10 +30,16 @@ stripDiff :: Functor syntax -> Diff.Diff syntax ann1 ann2 stripDiff = bimap snd snd +class HasDiffFor (term :: * -> *) where + type DiffFor term = (res :: * -> * -> *) | res -> term + class DiffTerms term diff | diff -> term, term -> diff where -- | Diff a 'These' of terms. diffTermPair :: These (term ann1) (term ann2) -> diff ann1 ann2 +instance HasDiffFor (Term syntax) where + type DiffFor (Term syntax) = Diff.Diff syntax + instance (Diffable syntax, Eq1 syntax, Hashable1 syntax, Traversable syntax) => DiffTerms (Term syntax) (Diff.Diff syntax) where diffTermPair = these Diff.deleting Diff.inserting diffTerms