From ae27e9cbbe897b2ea93bb0a382777c35232b53b4 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 18 Nov 2015 07:11:05 -0800 Subject: [PATCH] Move SES into its own file. --- src/Interpreter.hs | 5 ++--- src/SES.hs | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Interpreter.hs b/src/Interpreter.hs index c9f2b177c..325053327 100644 --- a/src/Interpreter.hs +++ b/src/Interpreter.hs @@ -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 diff --git a/src/SES.hs b/src/SES.hs index 472953cf9..dd593d6c5 100644 --- a/src/SES.hs +++ b/src/SES.hs @@ -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