diff --git a/src/Diff.hs b/src/Diff.hs index 9da5fadfd..4fff55707 100644 --- a/src/Diff.hs +++ b/src/Diff.hs @@ -41,11 +41,4 @@ mergeMaybe transform = cata algebra . fmap transform Keyed i -> Keyed (Map.fromList (Map.toList i >>= (\ (k, v) -> maybe [] (pure . (,) k) v))) beforeTerm :: Diff leaf annotation -> Maybe (Term leaf annotation) -beforeTerm = cata algebra - where algebra :: FreeF (CofreeF (Syntax leaf) (Both annotation)) (Patch (Term leaf annotation)) (Maybe (Term leaf annotation)) -> Maybe (Term leaf annotation) - algebra (Pure patch) = before patch - algebra (Free (annotations :< syntax)) = Just . cofree $ Both.fst annotations :< case syntax of - Leaf s -> Leaf s - Indexed i -> Indexed (catMaybes i) - Fixed i -> Fixed (catMaybes i) - Keyed i -> Keyed (Map.fromList (Map.toList i >>= (\ (k, v) -> maybe [] (pure . (,) k) v))) +beforeTerm = mergeMaybe before