mirror of
https://github.com/github/semantic.git
synced 2025-01-03 04:51:57 +03:00
Define a JSONFields bridge for ToJSON instances.
This commit is contained in:
parent
8c205e7114
commit
f43dc62d12
@ -28,3 +28,10 @@ instance (Apply1 Foldable fs) => ToJSONFields1 (Union fs) where
|
||||
|
||||
instance (ToJSON a, ToJSON b) => ToJSONFields (a, b) where
|
||||
toJSONFields (a, b) = [ "before" .= a, "after" .= b ]
|
||||
|
||||
|
||||
newtype JSONFields a = JSONFields { unJSONFields :: a }
|
||||
|
||||
instance (ToJSONFields a) => ToJSON (JSONFields a) where
|
||||
toJSON = object . toJSONFields . unJSONFields
|
||||
toEncoding = pairs . mconcat . toJSONFields . unJSONFields
|
||||
|
Loading…
Reference in New Issue
Block a user