-
Notifications
You must be signed in to change notification settings - Fork 7
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
refactor!: remove Value::Tuple
#1255
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1255 +/- ##
==========================================
+ Coverage 86.98% 87.05% +0.06%
==========================================
Files 102 102
Lines 19108 19223 +115
Branches 17015 17130 +115
==========================================
+ Hits 16622 16734 +112
- Misses 1709 1713 +4
+ Partials 777 776 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
uses new serialisation intermediary to keep serialized Tuple backwards compatibility BREAKING: `Value::Sum` now holds a standalone struct `Sum`
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 is great. I especially like SumSerial
. Could you add a small test that deserialises json with both Sums and Values serialised the old way?
Self { | ||
tag: value.tag, | ||
values: value.values, | ||
sum_type: Some(value.sum_type), |
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.
sum_type: Some(value.sum_type), | |
(value.sum_type.num_variants() > 1).then_some(value.sum_type), |
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 is schema breaking - Sums are not allowed to have null sum_type
(we won't be generating serialised "Tuple" from the rust any longer, I think to do that we would need to implement Serialize for Value
manually, which is annoying).
I'm happy with this compromise, but to really keep the "serialised tuple" optimisation I think we would want to rethink the serialised schema
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.
Oh, that is annoying.
#[serde(default)] | ||
tag: usize, | ||
#[serde(rename = "vs")] | ||
values: Vec<Value>, |
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.
I think we could omit this when it is empty. Value::unary_unit_sum
would then omit all fields! Relevant for values of any unary sum type. Perhaps this would be better as a future improvement.
sum_type.check_type(*tag, values)?; | ||
Ok(()) | ||
} | ||
} | ||
} | ||
|
||
/// If value is a sum with a single row variant, return the row. | ||
pub fn as_tuple(&self) -> Option<&[Value]> { |
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.
I think you should add this method to Sum
as well, and delegate to that here.
## 🤖 New release * `hugr`: 0.6.1 -> 0.7.0 * `hugr-core`: 0.3.1 -> 0.4.0 * `hugr-passes`: 0.3.0 -> 0.4.0 * `hugr-cli`: 0.1.2 -> 0.1.3 <details><summary><i><b>Changelog</b></i></summary><p> ## `hugr` <blockquote> ## 0.7.0 (2024-07-10) ### Bug Fixes - Bring back input_extensions serialized field in rust NodeSer ([#1275](#1275)) - [**breaking**] `ops::Module` now empty struct rather than unit struct ([#1271](#1271)) ### Features - Add `force_order` pass. ([#1285](#1285)) - [**breaking**] `MakeOpDef` has new `extension` method. ([#1266](#1266)) ### Refactor - [**breaking**] Remove `Value::Tuple` ([#1255](#1255)) - [**breaking**] Rename `HugrView` function type methods + simplify behaviour ([#1265](#1265)) ### Styling - Change "serialise" etc to "serialize" etc. ([#1251](#1251)) ### Testing - Add a test for [#1257](#1257) ([#1260](#1260)) </blockquote> ## `hugr-core` <blockquote> ## 0.4.0 (2024-07-10) ### Bug Fixes - Bring back input_extensions serialized field in rust NodeSer ([#1275](#1275)) - [**breaking**] `ops::Module` now empty struct rather than unit struct ([#1271](#1271)) ### Features - [**breaking**] `MakeOpDef` has new `extension` method. ([#1266](#1266)) ### Refactor - [**breaking**] Remove `Value::Tuple` ([#1255](#1255)) - [**breaking**] Rename `HugrView` function type methods + simplify behaviour ([#1265](#1265)) ### Styling - Change "serialise" etc to "serialize" etc. ([#1251](#1251)) ### Testing - Add a test for [#1257](#1257) ([#1260](#1260)) </blockquote> ## `hugr-passes` <blockquote> ## 0.4.0 (2024-07-10) ### Features - Add `force_order` pass. ([#1285](#1285)) ### Refactor - [**breaking**] Remove `Value::Tuple` ([#1255](#1255)) </blockquote> ## `hugr-cli` <blockquote> ## 0.1.3 (2024-07-10) ### Styling - Change "serialise" etc to "serialize" etc. ([#1251](#1251)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/).
Closes #1206
uses new serialisation intermediary to keep serialized Tuple backwards compatibility
Snaps updated because a tuple-like sum always uses tuple display now
BREAKING CHANGE:
Value::Tuple
removed.Value::Sum
now holds a standalone structSum