diff --git a/lib/GEODE/Metadata/Types.hs b/lib/GEODE/Metadata/Types.hs index 9e7e6f8706fb35cca065f391f92c964a153df333..c2a81e55a81010f860ba7883c4492c213de357f9 100644 --- a/lib/GEODE/Metadata/Types.hs +++ b/lib/GEODE/Metadata/Types.hs @@ -44,10 +44,15 @@ class ToJSONObject a where toJSONObject :: a -> Object toJSONPairs :: a -> Series +instance {-# OVERLAPPABLE #-} (ToJSONObject a, ToJSONObject b) => + ToJSONObject (a @ b) where + toJSONObject (a :@: b) = toJSONObject a `Object.union` toJSONObject b + toJSONPairs (a :@: b) = toJSONPairs a <> toJSONPairs b + instance {-# OVERLAPPABLE #-} (ToJSONObject a, ToJSONObject b) => ToJSON (a @ b) where - toJSON (a :@: b) = Object $ toJSONObject a `Object.union` toJSONObject b - toEncoding (a :@: b) = pairs $ toJSONPairs a <> toJSONPairs b + toJSON = Object . toJSONObject + toEncoding = pairs . toJSONPairs instance {-# OVERLAPPABLE #-} (FromJSON a, FromJSON b) => FromJSON (a @ b) where parseJSON o = (:@:) <$> parseJSON o <*> parseJSON o