Open alexbiehl opened 6 years ago
(Or in general allow efficient encoding of this composite keys)
Hey, sorry I missed this!
Exporting this in some way sounds good. I wonder if the module should be suffixed with Unsafe
or Internal
?
It might be nice to expose the date/time encoders as a separate package like you did with the parsers. Perhaps iso8601-builder
?
At work we have a JSON schema which demands composite keys for objects of this form:
Now, we used the venerable
toKey (n, d) = Text.pack (show n ++ '_' ++ show d)
but this turned out out to show up in our profiling and really was taking 10% of our overall runtime! So we went for some cruel hack:Unfortunately this results in invalid JSON as
Encoding.day
is wrapped into quotes! It would be really neat if we could access the unsafe stuff from Data.Aeson.Encoding.Builder to use theDay
encoding without quotes.