1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 13:02:37 +03:00

Define a JSONFields1 bridge for ToJSON instances.

This commit is contained in:
Rob Rix 2017-09-10 22:32:07 -04:00
parent f43dc62d12
commit f8f3e6466d

View File

@ -35,3 +35,10 @@ newtype JSONFields a = JSONFields { unJSONFields :: a }
instance (ToJSONFields a) => ToJSON (JSONFields a) where
toJSON = object . toJSONFields . unJSONFields
toEncoding = pairs . mconcat . toJSONFields . unJSONFields
newtype JSONFields1 f a = JSONFields1 { unJSONFields1 :: f a }
instance (ToJSON a, ToJSONFields1 f) => ToJSON (JSONFields1 f a) where
toJSON = object . toJSONFields1 . unJSONFields1
toEncoding = pairs . mconcat . toJSONFields1 . unJSONFields1