1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 07:55:12 +03:00

Move SES into its own file.

This commit is contained in:
Rob Rix 2015-11-18 07:11:05 -08:00
parent b122712470
commit ae27e9cbbe
2 changed files with 8 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import Diff
import Syntax
import Data.Map
import Patch
import SES
constructAndRun :: Term a Info -> Term a Info -> Maybe (Diff a)
constructAndRun a b =
@ -35,9 +36,7 @@ run (Free (ByKey a b f)) = run $ f byKey where
inserted = (Pure . Insert) <$> difference b a
patched = intersectionWith interpret a b
run (Free (ByIndex a b f)) = run $ f $ ses a b where
ses a b | Prelude.null a = (Pure . Insert) <$> b
ses a b | Prelude.null b = (Pure . Delete) <$> a
run (Free (ByIndex a b f)) = run $ f $ ses a b
interpret :: Term a Info -> Term a Info -> Diff a
interpret a b = maybeReplace $ constructAndRun a b where

View File

@ -1 +1,7 @@
module SES where
import Patch
import Control.Monad.Free
ses a b | Prelude.null a = (Pure . Insert) <$> b
ses a b | Prelude.null b = (Pure . Delete) <$> a