From b20e4c195f8ea50d5748fd226f9fe8e6141e81dd Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 1 Nov 2016 15:04:43 -0500 Subject: [PATCH] Add ToJSON (Record fields) type class constraints --- src/Diffing.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Diffing.hs b/src/Diffing.hs index 919a37060..4dae1d903 100644 --- a/src/Diffing.hs +++ b/src/Diffing.hs @@ -32,7 +32,7 @@ import Term import TreeSitter import Text.Parser.TreeSitter.Language import qualified Data.Text as T -import Data.Aeson (toJSON, toEncoding) +import Data.Aeson (ToJSON, toJSON, toEncoding) import Data.Aeson.Encoding (encodingToLazyByteString) -- | Given a parser and renderer, diff two sources and return the rendered @@ -127,7 +127,7 @@ diffCostWithCachedTermCosts diff = unCost $ case runFree diff of Pure patch -> sum (cost . extract <$> patch) -- | Returns a rendered diff given a parser, diff arguments and two source blobs. -textDiff :: (DefaultFields fields, HasField fields Cost) => Parser (Syntax Text) (Record fields) -> DiffArguments -> Both SourceBlob -> IO Output +textDiff :: (ToJSON (Record fields), DefaultFields fields, HasField fields Cost) => Parser (Syntax Text) (Record fields) -> DiffArguments -> Both SourceBlob -> IO Output textDiff parser arguments = diffFiles parser $ case format arguments of Split -> split Patch -> patch @@ -143,7 +143,7 @@ truncatedDiff arguments sources = pure $ case format arguments of Summary -> SummaryOutput mempty -- | Prints a rendered diff to stdio or a filepath given a parser, diff arguments and two source blobs. -printDiff :: (DefaultFields fields, HasField fields Cost) => Parser (Syntax Text) (Record fields) -> DiffArguments -> Both SourceBlob -> IO () +printDiff :: (ToJSON (Record fields), DefaultFields fields, HasField fields Cost) => Parser (Syntax Text) (Record fields) -> DiffArguments -> Both SourceBlob -> IO () printDiff parser arguments sources = do rendered <- textDiff parser arguments sources let renderedText = case rendered of