Skip to content

Conversation

@mheinzel
Copy link
Collaborator

@mheinzel mheinzel commented Aug 12, 2024

We can revisit this once we focus on robustness, including error handling during run merges.

Copy link
Collaborator

@jorisdral jorisdral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Small but unrelated comment below

Copy link
Collaborator

@jorisdral jorisdral Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to move the ResolveValue Word64 instance to the test suite, since it might/will conflict with user instance. Or, alternatively, you can use a newtype in the style of Data.Monoid.Sum as an example, and it might be useful as a modifier as well for making number types into instances of ResolveValue

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially also wanted to provide an instance for Sum, but it's trickier than I thought. resolveDeserialised requires an instance SerialiseValue (Sum a) (and I didn't want to coerce things based on SerialiseValue a because the instances might disagree), but I'm not sure we generally want to have instance SerialiseValue a => SerialiseValue (Sum a). But if we don't, users would have to define an orphan instance for e.g. SerialiseValue (Sum Foo), which seems wrong.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can provide instances SerialiseValue (Sum Word64) and ResolveValue (Sum Word64) specifically, maybe that's an okay compromise?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the SerialiseValue (Sum Word64) and ResolveValue (Sum Word64) instances. I squashed the commit and re-based with main in anticipation of merging.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per a discussion with @mheinzel:

Regarding the instance SerialiseValue a => SerialiseValue (Sum a), it essentially states that the Sum newtype is transparent to serialization. This assertion is not unreasonable, as it is highly improbable one would serialize Sum a differently than a.

Hence we can have the more useful polymorphic instance:

instance (Num a, SerialiseValue a) => ResolveValue (Sum a)

@recursion-ninja recursion-ninja force-pushed the mheinzel/resolve-value-totality branch 4 times, most recently from b5efea7 to ada7ef0 Compare August 15, 2024 15:14
Copy link
Collaborator Author

@mheinzel mheinzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last detail, then we can merge.

tests = testGroup "Test.Database.LSMTree.Monoidal"
[ testGroup "Word64" (allProperties @Word64 False)
-- TODO: revisit totality (drop requirement or fix @SerialiseValue Word64@)
[ testGroup "Word64" (allProperties @Word64)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I thought we would just use the existing instance for ResolveValue (Sum Word64) instead of defining an orphan instance.

@mheinzel mheinzel dismissed jorisdral’s stale review August 15, 2024 17:32

Has been addressed, but Joris is away.

@recursion-ninja recursion-ninja force-pushed the mheinzel/resolve-value-totality branch 3 times, most recently from 0289087 to 488a9d6 Compare August 19, 2024 14:10
@recursion-ninja recursion-ninja self-assigned this Aug 19, 2024
@recursion-ninja recursion-ninja force-pushed the mheinzel/resolve-value-totality branch from 488a9d6 to bfd74ac Compare August 19, 2024 17:10
@mheinzel mheinzel added this pull request to the merge queue Aug 19, 2024
Merged via the queue into main with commit f09a04a Aug 19, 2024
@mheinzel mheinzel deleted the mheinzel/resolve-value-totality branch August 19, 2024 19:59
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.

4 participants