mirror of
https://github.com/github/semantic.git
synced 2025-01-02 04:10:29 +03:00
Define a HasDiffFor class with a type family for the diff.
This commit is contained in:
parent
e8279b9081
commit
678d586ec5
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user