-
Notifications
You must be signed in to change notification settings - Fork 321
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
Option nullaryToObject to encode/decode nullary constructors as empty objects #926
Open
epoberezkin
wants to merge
10
commits into
haskell:master
Choose a base branch
from
simplex-chat:ep/nullary-to-object
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a2ebcde
an option to encode nullary constructors as empty objects
epoberezkin cf20b10
export nullaryToObject
epoberezkin bd59bc6
use nullaryToObject option in ToJSON
epoberezkin 3eb66f9
change if to guards, comments
epoberezkin 68330dc
Merge branch 'master' into ep/nullary-to-object
epoberezkin 2cd8d94
fix nullaryToObject option for toJSON, add TH toJSON/toEncoding suppo…
epoberezkin 787e4a8
add TH parsing support for nullaryToObject, fail on non-empty objects…
epoberezkin 7cdbd01
remove unused name from TH, update comment
epoberezkin 049feff
make parsers depend on nullaryToObject option (do not relax default p…
epoberezkin 7b8f95e
Merge branch 'master' into ep/nullary-to-object
epoberezkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not right. You accept
{}
even ifnullaryToObject
isFalse
, i.e. relaxing the parser. And vice versa,nullaryToObject = True
case will accept[]
.As I said, I'm not a fan of extending the kitchen-sink existing deriving mechanism. There are just too many interacting options.
I really suggest that you create your own generic serializing/deserializing fit for your needs. It will be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, it was intended - what's the harm here?
But happy to make it follow the option - I will do that, it's easy.
Well, our needs are very close to what aeson does, it's not our job to make a better JSON library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phadej so now these parsers depend on this option, so the default parsers are not relaxed. Tests are amended too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aeson
is not justGeneric
deriving. Generic deriving is just a (smalL) part (and IMO the not very great part) of a library, and is redone in other libraries, like https://hackage.haskell.org/package/deriving-aeson , https://hackage.haskell.org/package/autodocodec-0.2.1.0/docs/Autodocodec-Aeson.html, https://hackage.haskell.org/package/json-sopThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's ok, it amends TH too. We will be switching to TH anyway.