From 8c5d0bf2da8c6cb23a470c48afa2c19f7fb5a1cd Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 26 May 2017 10:42:39 -0400 Subject: [PATCH] Generalize patch rendering over the syntax functor. --- src/Renderer.hs | 2 +- src/Renderer/Patch.hs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Renderer.hs b/src/Renderer.hs index 15e4f80ca..890d4cb9a 100644 --- a/src/Renderer.hs +++ b/src/Renderer.hs @@ -26,7 +26,7 @@ import Term data Renderer input output where - PatchRenderer :: HasField fields Range => Renderer (Both SourceBlob, Diff (Syntax Text) (Record fields)) File + PatchRenderer :: (HasField fields Range, Traversable f) => Renderer (Both SourceBlob, Diff f (Record fields)) File JSONRenderer :: (ToJSON a, Foldable t) => Renderer (t SourceBlob, a) [Value] SExpressionDiffRenderer :: (HasField fields Category, HasField fields SourceSpan, Foldable f) => Renderer (Both SourceBlob, Diff f (Record fields)) ByteString ToCRenderer :: (HasField fields Category, HasField fields (Maybe Declaration), HasField fields SourceSpan) => Renderer (Both SourceBlob, Diff (Syntax Text) (Record fields)) Summaries diff --git a/src/Renderer/Patch.hs b/src/Renderer/Patch.hs index 24d890357..15bcef62c 100644 --- a/src/Renderer/Patch.hs +++ b/src/Renderer/Patch.hs @@ -18,7 +18,6 @@ import Prologue hiding (fst, snd) import Range import qualified Source import Source hiding (break, drop, length, null, take) -import Syntax import SplitDiff -- | Render a timed out file as a truncated diff. @@ -26,7 +25,7 @@ truncatePatch :: Both SourceBlob -> Text truncatePatch blobs = header blobs <> "#timed_out\nTruncating diff: timeout reached.\n" -- | Render a diff in the traditional patch format. -patch :: HasField fields Range => Both SourceBlob -> Diff (Syntax Text) (Record fields) -> Text +patch :: (HasField fields Range, Traversable f) => Both SourceBlob -> Diff f (Record fields) -> Text patch blobs diff = if not (Text.null text) && Text.last text /= '\n' then text <> "\n\\ No newline at end of file\n" else text