Skip to content

Documentation examples for generic instances for ToJSONKey fail to compile #1145

Description

@soenkehahn

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.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions