1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +03:00

Use the diffThese combinator to recur in linear decomposition.

This commit is contained in:
Rob Rix 2017-02-23 14:12:39 -05:00
parent c6461ce94c
commit 36ae3053b4

View File

@ -108,14 +108,11 @@ decompose :: (Eq1 f, GAlign f, Traversable f, HasField fields Category, HasField
=> AlgorithmF (Term f (Record fields)) (Diff f (Record fields)) result -- ^ The step in an algorithm to decompose into its next steps.
-> Algorithm (Term f (Record fields)) (Diff f (Record fields)) result -- ^ The sequence of next steps to undertake to continue the algorithm.
decompose = \case
Linear t1 t2 -> case galignWith recur (unwrap t1) (unwrap t2) of
Linear t1 t2 -> case galignWith diffThese (unwrap t1) (unwrap t2) of
Just result -> annotate t1 t2 <$> sequenceA result
_ -> byReplacing t1 t2
RWS as bs -> pure (rws recur' as bs)
RWS as bs -> pure (rws undefined comparable as bs)
Delete a -> pure (deleting a)
Insert b -> pure (inserting b)
Replace a b -> pure (replacing a b)
where recur = these byDeleting byInserting linearly
annotate t1 t2 = wrap . (both (extract t1) (extract t2) :<)
recur' :: Term f (Record fields) -> Term f (Record fields) -> Maybe (Diff f (Record fields))
recur' = undefined
where annotate t1 t2 = wrap . (both (extract t1) (extract t2) :<)