Skip to content
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

Export isEmptyArray from Data.Aeson.Types #694

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

callummance
Copy link

Export isEmptyArray found in Data.Aeson.Types.Internal from Data.Aeson.Types.

@bergmark
Copy link
Collaborator

Thanks for the contribution!

My initial thought was that it's a bit weird that we have a function Value -> Bool. Just looking at the type signature it could have a lot of implementations. And if isEmptyArray x == False you might think you have a non-empty array, but in this case you could also have something else. Seems we only use it in one place inside aeson btw!

Instead, maybe we could have a function withArrayRenameMe :: a -> (Array-> a) -> Value -> a (withArray is already taken) and then you could write withArray False V.null instead to be explicit about what happens if you don't have an Array. I think the type also gives more indication of what the implementation is. Maybe stick several of these functions inside a new module like Data.Aeson.ValueCombinators. Maybe withArray could be implemented in terms of this new function.

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants