-
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
Add Data.Aeson.Key.length
#1123
Comments
Why you need to know the key length. If you do something text-y with keys, then IMO conversion to EDIT: also length is O(n) operation, and I feel uncomfortable adding "slow" functions. I bet someone will then ask whether it can be made O(1) etc, a development I don't want to engage with. |
For example, I want to validate labels to add to a resource, and label keys are capped at 63 characters, but I don't want to do any more analysis than that, and I'm only passing
which are specified as UTF-8, that is a ceiling to our opacity
Aeson is already generating intermediate
You are already engaging with this small PR, I imagine you will have no problem saying "no" to that person. |
that is textual value. Those are not keys. SOrry. I think the way to do it is to explicitly convert to |
The JSON spec requires UTF-8 encoding (source). So the notion of the length of a key, defined as number of code points, seems well-defined.
The best way I've found is
Data.Text.length . Data.Aeson.Key.toText
which requires keeping up with current (unspecified) implementation to avoid extra work, plus addingtext
to explicit dependencies if not already there.Happy to toss in a PR if deemed reasonable.
The text was updated successfully, but these errors were encountered: