aeson 2.2 support
Closed this issue · 2 comments
not sure how to fix this code after aeson 2.2 changes,
current cabal limits <2.2 but for better compatibility with other things I want it to build with aeson 2.2.1
so I need little help
(.?=) :: (Aeson.ToJSON v, Aeson.KeyValue kv) => Aeson.Key -> Maybe v -> Maybe kv
k .?= Just v = Just (k Aeson..= v)
_ .?= Nothing = Nothing
(.=) :: (Aeson.ToJSON v, Aeson.KeyValue kv) => Aeson.Key -> v -> Maybe kv
k .= v = Just (k Aeson..= v)
class CalamityToJSON' a where
toPairs :: Aeson.KeyValue kv => a -> [Maybe kv]
newtype CalamityToJSON a = CalamityToJSON a
instance CalamityToJSON' a => Aeson.ToJSON (CalamityToJSON a) where
toJSON (CalamityToJSON x) = Aeson.object . catMaybes . toPairs $ x
toEncoding (CalamityToJSON x) = Aeson.pairs . mconcat . catMaybes . toPairs $ x
it gives
• Expecting one more argument to ‘Aeson.KeyValue kv’
Expected a constraint,
but ‘Aeson.KeyValue kv’ has kind
‘* -> Constraint’
• In the type signature:
toPairs :: Aeson.KeyValue kv => a -> [Maybe kv]
In the class declaration for ‘CalamityToJSON'’
|
| toPairs :: Aeson.KeyValue kv => a -> [Maybe kv]
I directed @Miezhiko to convert Aeson.KeyValue kv
to Aeson.KeyValue e kv
in the functional programming discord. That seemed to fix this error.
this change will break 2.1 compat most likely,
issue is actual on whether it's worthwhile to use CPP to maintain compatibility or whether to just drop support for aeson 2.1