From 7b37f3789f3acd63abf25fee328be0ed6b242edd Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 17 Oct 2019 22:43:03 -0400 Subject: [PATCH] Rename Data.Patch to Data.Edit. --- semantic.cabal | 2 +- src/Data/Diff.hs | 2 +- src/Data/{Patch.hs => Edit.hs} | 2 +- src/Data/JSON/Fields.hs | 2 +- src/Rendering/Graph.hs | 2 +- src/Rendering/JSON.hs | 4 ++-- src/Rendering/TOC.hs | 2 +- src/Serializing/SExpression.hs | 2 +- test/Data/Functor/Listable.hs | 2 +- test/Diffing/Interpreter/Spec.hs | 10 +++++++++- test/Rendering/TOC/Spec.hs | 2 +- 11 files changed, 20 insertions(+), 12 deletions(-) rename src/Data/{Patch.hs => Edit.hs} (98%) diff --git a/semantic.cabal b/semantic.cabal index dc5874931..ee1eb1796 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -148,6 +148,7 @@ library , Data.Blob.IO , Data.Diff , Data.Duration + , Data.Edit , Data.Error , Data.Flag , Data.Functor.Both @@ -160,7 +161,6 @@ library , Data.JSON.Fields , Data.Language , Data.Map.Monoidal - , Data.Patch , Data.Project , Data.Quieterm , Data.Semigroup.App diff --git a/src/Data/Diff.hs b/src/Data/Diff.hs index 39b778c8b..61eca38f7 100644 --- a/src/Data/Diff.hs +++ b/src/Data/Diff.hs @@ -18,10 +18,10 @@ import Data.Aeson import Data.Bifoldable import Data.Bifunctor import Data.Bitraversable +import Data.Edit import Data.Functor.Classes import Data.Functor.Foldable import Data.JSON.Fields -import Data.Patch import Data.Term import Text.Show diff --git a/src/Data/Patch.hs b/src/Data/Edit.hs similarity index 98% rename from src/Data/Patch.hs rename to src/Data/Edit.hs index 242b98ea6..5500f2afa 100644 --- a/src/Data/Patch.hs +++ b/src/Data/Edit.hs @@ -1,5 +1,5 @@ {-# LANGUAGE LambdaCase #-} -module Data.Patch +module Data.Edit ( Patch(..) , edit ) where diff --git a/src/Data/JSON/Fields.hs b/src/Data/JSON/Fields.hs index d81ab83e6..e0c938eee 100644 --- a/src/Data/JSON/Fields.hs +++ b/src/Data/JSON/Fields.hs @@ -9,8 +9,8 @@ module Data.JSON.Fields ) where import Data.Aeson +import Data.Edit import qualified Data.Map as Map -import Data.Patch import Data.Sum (Apply (..), Sum) import qualified Data.Text as Text import GHC.Generics diff --git a/src/Rendering/Graph.hs b/src/Rendering/Graph.hs index fece93f88..5994c724f 100644 --- a/src/Rendering/Graph.hs +++ b/src/Rendering/Graph.hs @@ -14,8 +14,8 @@ import Control.Effect.Reader import Control.Effect.State import Control.Lens import Data.Diff +import Data.Edit import Data.Graph -import Data.Patch import Data.ProtoLens (defMessage) import Data.String (IsString (..)) import Data.Term diff --git a/src/Rendering/JSON.hs b/src/Rendering/JSON.hs index 119e73ec3..10f522635 100644 --- a/src/Rendering/JSON.hs +++ b/src/Rendering/JSON.hs @@ -15,9 +15,9 @@ module Rendering.JSON import Data.Aeson (ToJSON, toJSON, object, (.=)) import Data.Aeson as A -import Data.JSON.Fields import Data.Blob -import Data.Patch +import Data.Edit +import Data.JSON.Fields import Data.Text (pack) import GHC.TypeLits import Prologue diff --git a/src/Rendering/TOC.hs b/src/Rendering/TOC.hs index 26337d9cd..1d27ee3f6 100644 --- a/src/Rendering/TOC.hs +++ b/src/Rendering/TOC.hs @@ -15,10 +15,10 @@ import Analysis.TOCSummary import Data.Align (bicrosswalk) import Data.Aeson (ToJSON(..), Value, (.=), object) import Data.Diff +import Data.Edit import Data.Language as Language import Data.List (sortOn) import qualified Data.Map.Monoidal as Map -import Data.Patch import Data.Term import qualified Data.Text as T import Source.Loc diff --git a/src/Serializing/SExpression.hs b/src/Serializing/SExpression.hs index c994a944f..7681fabe5 100644 --- a/src/Serializing/SExpression.hs +++ b/src/Serializing/SExpression.hs @@ -8,7 +8,7 @@ module Serializing.SExpression import Analysis.ConstructorName import Data.ByteString.Builder import Data.Diff -import Data.Patch +import Data.Edit import Data.Term import Prelude import Prologue diff --git a/test/Data/Functor/Listable.hs b/test/Data/Functor/Listable.hs index d42f76fdc..992407efd 100644 --- a/test/Data/Functor/Listable.hs +++ b/test/Data/Functor/Listable.hs @@ -20,10 +20,10 @@ import qualified Analysis.TOCSummary as ToC import Data.Abstract.ScopeGraph (AccessControl(..)) import Data.Bifunctor.Join import Data.Diff +import Data.Edit import Data.Functor.Both import qualified Data.Language as Language import Data.List.NonEmpty -import Data.Patch import qualified Data.Syntax as Syntax import qualified Data.Syntax.Comment as Comment import qualified Data.Syntax.Declaration as Declaration diff --git a/test/Diffing/Interpreter/Spec.hs b/test/Diffing/Interpreter/Spec.hs index d8a67d18c..1e42b1632 100644 --- a/test/Diffing/Interpreter/Spec.hs +++ b/test/Diffing/Interpreter/Spec.hs @@ -3,12 +3,12 @@ module Diffing.Interpreter.Spec (spec, afterTerm, beforeTerm) where import Control.Applicative ((<|>)) import Data.Diff +import Data.Edit (edit) import Data.Foldable (asum) import Data.Functor.Foldable (cata) import Data.Functor.Listable import Data.Maybe import Data.Mergeable -import Data.Patch (after, before) import Data.Sum import Data.Term import Data.These @@ -81,5 +81,13 @@ afterTerm = cata $ \ diff -> case diff of Patch patch -> (after patch >>= \ (In b r) -> termIn b <$> sequenceAlt r) <|> (before patch >>= asum) Merge (In (_, b) r) -> termIn b <$> sequenceAlt r +-- | Return the item from the after side of the patch. +after :: Patch l r -> Maybe r +after = edit (const Nothing) Just (\ _ b -> Just b) + +-- | Return the item from the before side of the patch. +before :: Patch l r -> Maybe l +before = edit Just (const Nothing) (\ a _ -> Just a) + emptyAnnotation :: () emptyAnnotation = () diff --git a/test/Rendering/TOC/Spec.hs b/test/Rendering/TOC/Spec.hs index bfcd90a2b..5d6a669cb 100644 --- a/test/Rendering/TOC/Spec.hs +++ b/test/Rendering/TOC/Spec.hs @@ -7,8 +7,8 @@ import Control.Effect.Reader import Data.Aeson hiding (defaultOptions) import Data.Bifunctor import Data.Diff +import Data.Edit import Data.Either (isRight) -import Data.Patch import Data.Sum import Data.Term import Data.Text (Text)