diff --git a/src/Semantic/Diff.hs b/src/Semantic/Diff.hs index ce40ced78..e16252755 100644 --- a/src/Semantic/Diff.hs +++ b/src/Semantic/Diff.hs @@ -24,6 +24,7 @@ import Serializing.Format import Rendering.JSON (SomeJSON (..)) import qualified Rendering.JSON as JSON +-- | Using the specified renderer, diff a list of 'BlobPair's to produce a 'Builder' output. runDiff :: (Member Distribute effs, Member (Exc SomeException) effs, Member (Lift IO) effs, Member Task effs, Member Telemetry effs) => DiffRenderer output -> [BlobPair] -> Eff effs Builder runDiff ToCDiffRenderer = withParsedBlobPairs (decorate . declarationAlgebra) (render . renderToCDiff) >=> serialize JSON runDiff JSONDiffRenderer = withParsedBlobPairs (decorate . unitAlgebra) (\blob -> render (renderJSONDiff blob) . bimap snd snd) >=> serialize JSON @@ -47,9 +48,10 @@ diffBlobTOCPairs :: (Member Distribute effs, Member (Exc SomeException) effs, Me diffBlobTOCPairs = withParsedBlobPairs (decorate . declarationAlgebra) (render . renderRPCToCDiff) type CanDiff syntax = (ConstructorName syntax, Diffable syntax, Eq1 syntax, HasDeclaration syntax, Hashable1 syntax, Show1 syntax, ToJSONFields1 syntax, Traversable syntax) +type Decorate effs a b = forall syntax . CanDiff syntax => Blob -> Term syntax a -> Eff effs (Term syntax b) withParsedBlobPairs :: (Member Distribute effs, Member (Exc SomeException) effs, Member (Lift IO) effs, Member Task effs, Member Telemetry effs, Monoid output) - => (forall syntax . CanDiff syntax => Blob -> Term syntax Location -> Eff effs (Term syntax (DiffAnnotation a))) + => Decorate effs Location (DiffAnnotation a) -> (forall syntax . CanDiff syntax => BlobPair -> Diff syntax (DiffAnnotation a) (DiffAnnotation a) -> Eff effs output) -> [BlobPair] -> Eff effs output @@ -61,7 +63,7 @@ withParsedBlobPairs decorate render = distributeFoldMap (\ blobs -> withParsedBl where languageTag = languageTagForBlobPair blobs withParsedBlobPair :: (Member Distribute effs, Member (Exc SomeException) effs, Member Task effs) - => (forall syntax . (CanDiff syntax) => Blob -> Term syntax Location -> Eff effs (Term syntax (DiffAnnotation a))) + => Decorate effs Location (DiffAnnotation a) -> BlobPair -> Eff effs (SomeTermPair '[ConstructorName, Diffable, Eq1, HasDeclaration, Hashable1, Show1, ToJSONFields1, Traversable] (DiffAnnotation a)) withParsedBlobPair decorate blobs