diff --git a/src/Semantic.hs b/src/Semantic.hs index 4ee161b4c..4c6989f04 100644 --- a/src/Semantic.hs +++ b/src/Semantic.hs @@ -49,26 +49,26 @@ parseDiffAndRenderBlobPair renderer blobs = case renderer of terms <- distributeFor blobs $ \ blob -> do term <- parseSource blob decorate (declarationAlgebra (source blob)) term - diffAndRenderTermPair blobs (runBothWith diffTerms) renderToC terms + diffAndRenderTermPair blobs (runBothWith diffTerms) (renderToC blobs) terms JSONDiffRenderer -> do terms <- distributeFor blobs (decorate identifierAlgebra <=< parseSource) - diffAndRenderTermPair blobs (runBothWith diffTerms) renderJSONDiff terms - PatchDiffRenderer -> distributeFor blobs parseSource >>= diffAndRenderTermPair blobs (runBothWith diffTerms) renderPatch + diffAndRenderTermPair blobs (runBothWith diffTerms) (renderJSONDiff blobs) terms + PatchDiffRenderer -> distributeFor blobs parseSource >>= diffAndRenderTermPair blobs (runBothWith diffTerms) (renderPatch blobs) SExpressionDiffRenderer -> case effectiveLanguage of - Just Language.Python -> distributeFor blobs parseSource >>= diffAndRenderTermPair blobs (runBothWith replacing) (const renderSExpressionDiff) - _ -> distributeFor blobs parseSource >>= diffAndRenderTermPair blobs (runBothWith diffTerms) (const renderSExpressionDiff) + Just Language.Python -> distributeFor blobs parseSource >>= diffAndRenderTermPair blobs (runBothWith replacing) renderSExpressionDiff + _ -> distributeFor blobs parseSource >>= diffAndRenderTermPair blobs (runBothWith diffTerms) renderSExpressionDiff IdentityDiffRenderer -> do terms <- distributeFor blobs $ \ blob -> do term <- parseSource blob decorate (declarationAlgebra (source blob)) term - diffAndRenderTermPair blobs (runBothWith diffTerms) (const identity) terms + diffAndRenderTermPair blobs (runBothWith diffTerms) identity terms where effectiveLanguage = runBothWith (<|>) (blobLanguage <$> blobs) parseSource = parse (parserForLanguage effectiveLanguage) . source -- | A task to diff a pair of 'Term's and render the 'Diff', producing insertion/deletion 'Patch'es for non-existent 'SourceBlob's. -diffAndRenderTermPair :: Functor f => Both SourceBlob -> Differ f a -> (Both SourceBlob -> Diff f a -> output) -> Both (Term f a) -> Task (Maybe output) +diffAndRenderTermPair :: Functor f => Both SourceBlob -> Differ f a -> (Diff f a -> output) -> Both (Term f a) -> Task (Maybe output) diffAndRenderTermPair blobs differ renderer terms = case runJoin (nonExistentBlob <$> blobs) of (True, True) -> pure Nothing - (_, True) -> Just <$> render (renderer blobs) (deleting (Both.fst terms)) - (True, _) -> Just <$> render (renderer blobs) (inserting (Both.snd terms)) - _ -> diff differ terms >>= fmap Just . render (renderer blobs) + (_, True) -> Just <$> render renderer (deleting (Both.fst terms)) + (True, _) -> Just <$> render renderer (inserting (Both.snd terms)) + _ -> diff differ terms >>= fmap Just . render renderer diff --git a/test/SemanticSpec.hs b/test/SemanticSpec.hs index 21461fd72..ee677c028 100644 --- a/test/SemanticSpec.hs +++ b/test/SemanticSpec.hs @@ -29,7 +29,7 @@ spec = parallel $ do describe "diffAndRenderTermPair" $ do it "produces Nothing when both blobs are missing" $ do - result <- runTask (diffAndRenderTermPair (pure (emptySourceBlob "/foo")) (runBothWith replacing) (\ _ _ -> ("non-empty" :: ByteString)) (pure (cofree (() :< [])))) + result <- runTask (diffAndRenderTermPair (pure (emptySourceBlob "/foo")) (runBothWith replacing) (const ("non-empty" :: ByteString)) (pure (cofree (() :< [])))) result `shouldBe` Nothing where