mirror of
https://github.com/github/semantic.git
synced 2025-01-02 20:41:38 +03:00
📝 diffTerms.
This commit is contained in:
parent
49d0fa7980
commit
04a3d52007
@ -24,8 +24,14 @@ type Comparable leaf annotation = Term leaf annotation -> Term leaf annotation -
|
||||
-- | Constructs a diff from the CofreeF containing its annotation and syntax. This function has the opportunity to, for example, cache properties in the annotation.
|
||||
type DiffConstructor leaf annotation = CofreeF (Syntax leaf) (Both annotation) (Diff leaf annotation) -> Diff leaf annotation
|
||||
|
||||
-- | Diff two terms, given a function that determines whether two terms can be compared and a cost function.
|
||||
diffTerms :: (Eq leaf, Hashable leaf, Eq (Record fields), HasField fields Category) => DiffConstructor leaf (Record fields) -> Comparable leaf (Record fields) -> SES.Cost (Diff leaf (Record fields)) -> Term leaf (Record fields) -> Term leaf (Record fields) -> Diff leaf (Record fields)
|
||||
-- | Diff two terms recursively, given functions characterizing the diffing.
|
||||
diffTerms :: (Eq leaf, Hashable leaf, Eq (Record fields), HasField fields Category) =>
|
||||
DiffConstructor leaf (Record fields) -> -- ^ A function to wrap up & possibly annotate every produced diff.
|
||||
Comparable leaf (Record fields) -> -- ^ A function to determine whether or not two terms should even be compared.
|
||||
SES.Cost (Diff leaf (Record fields)) -> -- ^ A function to compute the cost of a given diff node.
|
||||
Term leaf (Record fields) -> -- ^ A term representing the old state.
|
||||
Term leaf (Record fields) -> -- ^ A term representing the new state.
|
||||
Diff leaf (Record fields)
|
||||
diffTerms construct comparable cost a b = fromMaybe (replacing a b) $ diffComparableTerms construct comparable cost a b
|
||||
|
||||
diffComparableTerms :: (Eq leaf, Hashable leaf, Eq (Record fields), HasField fields Category) => DiffConstructor leaf (Record fields) -> Comparable leaf (Record fields) -> SES.Cost (Diff leaf (Record fields)) -> Term leaf (Record fields) -> Term leaf (Record fields) -> Maybe (Diff leaf (Record fields))
|
||||
|
Loading…
Reference in New Issue
Block a user