1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Define a function computing the equivalence of terms based on subequivalence.

This commit is contained in:
Rob Rix 2017-10-03 13:27:02 -04:00
parent 98ac25fe84
commit 82244515f8
2 changed files with 9 additions and 1 deletions

View File

@ -106,6 +106,14 @@ algorithmForTerms t1@(Term (In ann1 f1)) t2@(Term (In ann2 f2))
<|> insertF . In ann2 <$> subalgorithmFor byInserting ( mergeFor t1) f2
where mergeFor (Term (In ann1 f1)) (Term (In ann2 f2)) = merge (ann1, ann2) <$> algorithmFor f1 f2
equivalentTerms :: Diffable syntax
=> Term syntax ann1
-> Term syntax ann2
-> Bool
equivalentTerms term1@(Term (In _ syntax1)) term2@(Term (In _ syntax2))
= subequivalenceTo (flip equivalentTerms term2) syntax1
|| subequivalenceTo ( equivalentTerms term1) syntax2
-- | A type class for determining what algorithm to use for diffing two terms.
class Diffable f where
-- | Construct an algorithm to diff a pair of @f@s populated with disjoint terms.

View File

@ -6,7 +6,7 @@ module Interpreter
, equivalentTerms
) where
import Algorithm
import Algorithm hiding (equivalentTerms)
import Control.Applicative (Alternative(..))
import Control.Monad.Free.Freer
import Data.Align.Generic