1
1
mirror of https://github.com/github/semantic.git synced 2024-12-30 18:36:27 +03:00

🔥 NumberedLine.

This commit is contained in:
Rob Rix 2017-05-16 13:07:55 -04:00
parent cbf17cdc22
commit 036e472aab

View File

@ -31,16 +31,9 @@ json blobs diff = Map.fromList
, ("paths", toJSON (path <$> blobs))
]
-- | A numbered 'a'.
newtype NumberedLine a = NumberedLine (Int, a)
instance StringConv (Map Text Value) ByteString where
strConv _ = toS . (<> "\n") . encode
instance ToJSONFields a => ToJSON (NumberedLine a) where
toJSON (NumberedLine (n, a)) = object $ "number" .= n : toJSONFields a
toEncoding (NumberedLine (n, a)) = pairs $ "number" .= n <> mconcat (toJSONFields a)
instance ToJSON a => ToJSONFields (Join (,) a) where
toJSONFields (Join (a, b)) = [ "before" .= a, "after" .= b ]