1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Simplify with a foldMap.

This commit is contained in:
Rob Rix 2017-09-10 18:34:42 +01:00
parent 36ac6a4104
commit b4ca3be640

View File

@ -220,6 +220,6 @@ instance (ToJSONFields a, ToJSONFields1 f) => ToJSONFields (Diff f a) where
toJSONFields = toJSONFields . unDiff
instance (ToJSON b, ToJSONFields a, ToJSONFields1 f) => ToJSONFields (DiffF f a b) where
toJSONFields (Copy vs a f) = foldr (\ (Metavar k, v) -> (pack k .= v :)) [] vs <> toJSONFields a <> toJSONFields1 f
toJSONFields (Copy vs a f) = foldMap (\ (Metavar k, v) -> [pack k .= v]) vs <> toJSONFields a <> toJSONFields1 f
toJSONFields (Var (Metavar v)) = [ "metavar" .= v ]
toJSONFields (Patch a) = toJSONFields a