1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 16:02:43 +03:00

Go back to Diff SES.

This commit is contained in:
Rob Rix 2015-11-18 07:40:30 -08:00
parent cb6eeff9e3
commit 6d6fbcf797

View File

@ -2,8 +2,10 @@ module SES (ses) where
import Patch
import Diff
import Control.Monad.Free
ses :: Eq a => [a] -> [a] -> [Either (Patch a) (a, a)]
ses [] b = (Left . Insert) <$> b
ses a [] = (Left . Delete) <$> a
ses (a : as) (b : bs) | a == b = Right (a, b) : ses as bs
ses :: Functor f => Eq a => [a] -> [a] -> [Free f (Patch a)]
ses [] b = (Pure . Insert) <$> b
ses a [] = (Pure . Delete) <$> a
ses (a : as) (b : bs) = case recur a b of
Just f -> f : ses as bs