-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
amazonka-dynamodb: Use a sum type for AttributeValue #724
Conversation
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 looks great, my only comments relate to the in memory representation. I can't see much point in not using the most space efficient representations we can for a package like this. I'm sure most heavy users of the package would appreciate not having a large increase in memory size compared to the underlying JSON. I would be very surprised if laziness in the values is particularly useful here. Happy to discuss, but this is how I would design it for better performance/memory efficiency.
lib/services/amazonka-dynamodb/src/Amazonka/DynamoDB/Internal.hs
Outdated
Show resolved
Hide resolved
lib/services/amazonka-dynamodb/src/Amazonka/DynamoDB/Internal.hs
Outdated
Show resolved
Hide resolved
lib/services/amazonka-dynamodb/src/Amazonka/DynamoDB/Internal.hs
Outdated
Show resolved
Hide resolved
lib/services/amazonka-dynamodb/src/Amazonka/DynamoDB/Internal.hs
Outdated
Show resolved
Hide resolved
544f2ba
to
0982a07
Compare
Oh, and we'll need to repin stackage after merge. |
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.
See https://github.com/brendanhay/amazonka/tree/bh/dynamodb-mapper/amazonka-dynamodb-extras/src/Amazonka/DynamoDB for a blast from the past. It was mostly just random musings around what a layer above amazonka-dynamodb
might look like.
lib/services/amazonka-dynamodb/src/Amazonka/DynamoDB/Internal.hs
Outdated
Show resolved
Hide resolved
I had a look at your mapper; we have something a bit similar in an internal codebase. The main problem I have with the typeclass-driven approaches is that I often don't want to read/write an entire item - many of our operations are doing partial For this reason, I prefer building up encoder/decoders by combining values. If you keep an Anyway. I'll build up an internal test branch for work (with this, regen |
The branch is close to 6 years old - I likely now wouldn't use type classes either, as it currently stands. I just figured it might be of interest in regards to other functionality. |
Oh BTW @brendanhay do you want hand-written prisms instead of TH-generated ones? |
700bad1
to
c395162
Compare
Discovered that DynamoDB Streams has the same type. Not sure if there's a better way to do this. |
c395162
to
c20889b
Compare
And, annoyingly, stackage is on hashable-1.3.0.0 for GHC 8.10.7, which doesn't have |
c20889b
to
7a89fca
Compare
7a89fca
to
c270311
Compare
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.
🎉
https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchGetItem.html > If there are no unprocessed keys remaining, the response contains an > empty `UnprocessedKeys` map.
https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html > If there are no unprocessed items remaining, the response contains > an empty `UnprocessedItems` map.
lib/services/amazonka-dynamodb-streams/src/Amazonka/DynamoDBStreams/Internal.hs
Outdated
Show resolved
Hide resolved
Status update: generic-lens has a good story for prisms, and this branch makes using |
Gonna merge this now, but I've filed commercialhaskell/stackage#6386 to see how likely it we'll see Stackage LTS with GHC 8.10.x and |
Since amazonka-2.0 (whenever we get it out) won't make it into existing stackage LTS, stack users will have to extra-deps their way to victory. I'm comfortable with forcing them to add |
Note:
amazonka-2.0
RC1 (next week, most likely).--constraints 'aeson < 2.0'
as well as--constraints 'aeson >= 2.0'
.scripts/generate dynamodb
before testing, obviously.Open questions:
newtype
trick here in case AWS add more data types to dynamo? Feels a bit unlikely.lens
dependency - I'm prepared to write the prisms manually if necessary.