From 33bf8bc7f95a825b51f97e53848d39ef957546d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20G=C3=B3ngora?= Date: Fri, 12 Jun 2026 12:16:50 -0600 Subject: [PATCH] Address empty input edge cases --- src/Data/Algorithm/Diff.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Data/Algorithm/Diff.hs b/src/Data/Algorithm/Diff.hs index b564e37..9460f58 100644 --- a/src/Data/Algorithm/Diff.hs +++ b/src/Data/Algorithm/Diff.hs @@ -148,9 +148,9 @@ data DL = DL -- same /k-diagonal/, meaning that -- -- > poi x - poj x == poi y - poj y` --- +-- -- and both argument nodes are within the same wave front, --- +-- -- > length (path x) == length (path y) furthestReaching :: DL -> DL -> DL furthestReaching x y @@ -287,6 +287,8 @@ getGroupedDiff = getGroupedDiffBy (==) -- | A form of 'getDiff' with no 'Eq' constraint. Instead, an equality predicate -- is taken as the first argument. getDiffBy :: (a -> b -> Bool) -> [a] -> [b] -> [PolyDiff a b] +getDiffBy _ a [] = map First a +getDiffBy _ [] b = map Second b getDiffBy eq a b = markup a b . reverse $ ses eq a b where markup (x:xs) (y:ys) ds | eq x y = Both x y : markup xs ys ds