-
Notifications
You must be signed in to change notification settings - Fork 8
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
docs: Provide docs for array ops, fix bad doc for HugrView::poly_func_type #2021
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2021 +/- ##
==========================================
- Coverage 83.79% 83.09% -0.71%
==========================================
Files 211 215 +4
Lines 39763 40895 +1132
Branches 36435 37109 +674
==========================================
+ Hits 33320 33981 +661
- Misses 4567 5030 +463
- Partials 1876 1884 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
swap, | ||
/// separates leftmost element from the rest of the array. | ||
/// `pop_left<SIZE><elemty>: array<SIZE, elemty> -> Option<elemty, array<SIZE-1,elemty>>` |
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.
Note that if SIZE is 0, the u64 will (presumably) wrap, so the result type will be an Option<array<U64_MAX, elemty>>
which will be None at runtime.
Given SIZE
must be statically known, we could remove the Option:
pop_left<0>
could return Option of anything we want, or raise error incompute_signature
pop_left<1>
could return just the element (no Option nor array)pop_left<x>
whenx>=2
could return the element and rest of array (no Option)
and similarly for pop_right
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 seems like a return type you can't write down without a conditional, which is note very nice
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.
Hah, yes, OK maybe I've gone too far. See also #1521 though: even if we returned the element and a size-0 array in all cases N>=1, we could still avoid the option by erroring in compute_signature
for N==0. A lesser step but a good one?
Which is to say, I'll update/correct #1521 a bit and let's go from there
set, | ||
/// exchanges two indices within the array: `swap<size,elemty>: array<size, elemty>, index index -> either(array, array)` |
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.
/// exchanges two indices within the array: `swap<size,elemty>: array<size, elemty>, index index -> either(array, array)` | |
/// exchanges two indices within the array: `swap<size,elemty>: array<size, elemty>, index, index -> either(array, array)` |
swap, | ||
/// separates leftmost element from the rest of the array. | ||
/// `pop_left<SIZE><elemty>: array<SIZE, elemty> -> Option<elemty, array<SIZE-1,elemty>>` |
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 seems like a return type you can't write down without a conditional, which is note very nice
swap, | ||
/// separates leftmost element from the rest of the array. |
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.
mention None
indicates failure?
Co-authored-by: hugrbot <[email protected]>
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.
Nice. I think these strings belong in fn description()
, but this is surely an improvement so approving.
new_array, | ||
/// copies an element out of the array ([TypeBound::Copyable] elements only): |
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.
/// copies an element out of the array ([TypeBound::Copyable] elements only): | |
/// Copies an element out of the array ([TypeBound::Copyable] elements only): |
get, | ||
/// exchanges an element of the array with an external 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.
/// exchanges an element of the array with an external value: | |
/// Exchanges an element of the array with an external value: |
set, | ||
/// exchanges two indices within the array: |
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.
/// exchanges two indices within the array: | |
/// Exchanges two indices within the array: |
swap, | ||
/// separates leftmost element from the rest of the array: |
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.
/// separates leftmost element from the rest of the array: | |
/// Separates leftmost element from the rest of the array: |
pop_left, | ||
/// separates rightmost element from the rest of the array. |
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.
/// separates rightmost element from the rest of the array. | |
/// Separates rightmost element from the rest of the array. |
No description provided.