The documentation has an example for implementing ToJSONKey for a simple sum type:
data Color = Red | Green | Blue
deriving (Show, Read, Eq, Ord)
instance ToJSONKey Color where
toJSONKey = genericToJSONKey defaultJSONKeyOptions
However, when trying this I get two errors:
No instance for ‘ToJSON Color’
No instance for ‘Generic Color’
It'd be nice to have the examples compile.
(I was surprised that ToJSON was needed. So I looked at the example to clarify whether I'm really supposed to have that instance or whether I'm just using the library wrong. But since the example doesn't have the ToJSON instance, but also doesn't compile, I'm still not 100% sure.)
The documentation has an example for implementing
ToJSONKeyfor a simple sum type:However, when trying this I get two errors:
No instance for ‘ToJSON Color’No instance for ‘Generic Color’It'd be nice to have the examples compile.
(I was surprised that
ToJSONwas needed. So I looked at the example to clarify whether I'm really supposed to have that instance or whether I'm just using the library wrong. But since the example doesn't have theToJSONinstance, but also doesn't compile, I'm still not 100% sure.)