-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deriving FromField/ToField instances? #206
Comments
How these instances would work? |
There can't exist reasonable encoding for all cases, e.g. for product types. But it exists for subset of sum types with constructors of 0- or 1-arity: data Foo = Foo
data Foo = Bar | Baz Int It's similar to |
Enum case makes sense. 1-arity is suspicious. I'd suggest defining newtypes to be used with deriving via so the user tells what they want (instead of using clever generics trying to guess). That has an additional benefit that deriving mechanisms stay independent. FWIW, I plan to make that change to |
Works only for the following representations: * Single nullary constructor By default encodes constructor name * Sum with nullary or unary constructors Encoding is similar to 'UntaggedValue' encoding from 'aeson'
I think we can select precisely which instances to allow (see PR). |
Yeah, I like the idea. Current behavior is slightly confusing |
Works only for the following representations: * Single nullary constructor By default encodes constructor name * Sum with nullary or unary constructors Encoding is similar to 'UntaggedValue' encoding from 'aeson'
There is an API for deriving ToRecord/FromRecord instances, but none for ToField/FromField.
I looked through opened and closed issues and was unable to find any discussion regarding this.
Are there any deep reason's for not having generic instances for ToField/FromField?
The text was updated successfully, but these errors were encountered: