mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
Define an Output instance for JSONOutput.
This commit is contained in:
parent
e4ead782bc
commit
d1516c6f04
@ -14,7 +14,9 @@ import Data.Aeson as A
|
|||||||
import Data.JSON.Fields
|
import Data.JSON.Fields
|
||||||
import Data.Blob
|
import Data.Blob
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
|
import Data.ByteString.Lazy (toStrict)
|
||||||
import qualified Data.Map.Monoidal as Monoidal
|
import qualified Data.Map.Monoidal as Monoidal
|
||||||
|
import Data.Output
|
||||||
import Data.Patch
|
import Data.Patch
|
||||||
import Prologue
|
import Prologue
|
||||||
|
|
||||||
@ -25,6 +27,10 @@ toJSONOutput :: Text -> [Value] -> JSONOutput
|
|||||||
toJSONOutput key = JSONOutput . Monoidal.singleton key
|
toJSONOutput key = JSONOutput . Monoidal.singleton key
|
||||||
|
|
||||||
|
|
||||||
|
instance Output JSONOutput where
|
||||||
|
toOutput = toStrict . encode . unJSONOutput
|
||||||
|
|
||||||
|
|
||||||
-- | Render a diff to a value representing its JSON.
|
-- | Render a diff to a value representing its JSON.
|
||||||
renderJSONDiff :: ToJSON a => BlobPair -> a -> [Value]
|
renderJSONDiff :: ToJSON a => BlobPair -> a -> [Value]
|
||||||
renderJSONDiff blobs diff = pure $
|
renderJSONDiff blobs diff = pure $
|
||||||
|
Loading…
Reference in New Issue
Block a user