Skip to content

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