Skip to content
Snippets Groups Projects
Commit ed58c5cf authored by Alice Brenon's avatar Alice Brenon
Browse files

Directly implement ToJSON on @ instead of an intermediate ToJSONObject =>...

Directly implement ToJSON on @ instead of an intermediate ToJSONObject => ToJSON to avoid confusing the compiler
parent 410a2006
No related branches found
No related tags found
No related merge requests found
......@@ -35,9 +35,10 @@ class ToJSONObject a where
toJSONObject :: a -> Object
toJSONPairs :: a -> Series
instance {-# OVERLAPPABLE #-} ToJSONObject a => ToJSON a where
toJSON = Object . toJSONObject
toEncoding = pairs . toJSONPairs
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
instance {-# OVERLAPPABLE #-} (FromJSON a, FromJSON b) => FromJSON (a @ b) where
parseJSON o = (:@:) <$> parseJSON o <*> parseJSON o
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment