hdiff-0.0.1: Pattern-Expression-based differencing of arbitrary types.

Safe HaskellNone
LanguageHaskell2010

Data.HDiff.Patch

Contents

Synopsis

Patches

type RawPatch ki codes = Holes ki codes (CChange ki codes) Source #

Instead of keeping unecessary information, a RawPatch will factor out the common prefix before the actual changes.

type Patch ki codes ix = Holes ki codes (CChange ki codes) (I ix) Source #

A Patch is a RawPatch instantiated to I atoms.

Patch Alpha Equivalence

patchEq :: EqHO ki => RawPatch ki codes at -> RawPatch ki codes at -> Bool Source #

patchIsCpy :: EqHO ki => RawPatch ki codes at -> Bool Source #

Functionality over a Patch

patchMaxVar :: RawPatch ki codes at -> Int Source #

withFreshNamesFrom :: RawPatch ki codes at -> RawPatch ki codes at -> RawPatch ki codes at Source #

Calling p withFreshNamesFrom q will return an alpha equivalent version of p that has no name clasehs with q.

patchCost :: RawPatch ki codes at -> Int Source #

Computes the cost of a Patch. This is in the sense of edit-scripts where it counts how many constructors are being inserted and deleted.

Applying a Patch

Patch application really is trivial. Say we are applying a patch p against an element x, first we match x with the ctxDel p; upon a succesfull match we record, in a Valuation, which tree fell in which hole. Then, we use the same valuation to inject those trees into ctxIns p.

The only slight trick is that we need to wrap our trees in existentials inside our valuation.

apply :: (TestEquality ki, EqHO ki, ShowHO ki, IsNat ix) => Patch ki codes ix -> Fix ki codes ix -> Either String (Fix ki codes ix) Source #

Applying a patch is trivial, we simply project the deletion treefix and inject the valuation into the insertion.

Specializing a Patch

composes :: (ShowHO ki, EqHO ki, TestEquality ki) => RawPatch ki codes at -> RawPatch ki codes at -> Bool Source #

The predicate composes qr pq checks whether qr is immediatly applicable to the codomain of pq.

applicableTo :: (ShowHO ki, EqHO ki, TestEquality ki) => Holes ki codes (MetaVarIK ki) ix -> Holes ki codes (MetaVarIK ki) ix -> Bool Source #

substInsert' :: (ShowHO ki, EqHO ki, TestEquality ki) => String -> Subst ki codes (MetaVarIK ki) -> MetaVarIK ki ix -> Holes ki codes (MetaVarIK ki) ix -> Except (ApplicationErr ki codes (MetaVarIK ki)) (Subst ki codes (MetaVarIK ki)) Source #