1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 13:51:44 +03:00

🔥 the ToJSON instance for Join These.

This commit is contained in:
Rob Rix 2017-05-16 12:43:12 -04:00
parent cb9ec9e65e
commit 6b60a572f5

View File

@ -11,7 +11,6 @@ import Data.Aeson as A hiding (json)
import Data.Bifunctor.Join
import Data.Functor.Both
import Data.Record
import Data.These
import Data.Vector as Vector hiding (toList)
import Diff
import Info
@ -43,10 +42,6 @@ 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 => ToJSON (Join These a) where
toJSON (Join vs) = A.Array . Vector.fromList $ toJSON <$> these pure pure (\ a b -> [ a, b ]) vs
toEncoding = foldable
instance ToJSON a => ToJSONFields (Join (,) a) where
toJSONFields (Join (a, b)) = [ "before" .= a, "after" .= b ]