-
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
feat!: Extend LowerTypes pass to linearize by inserting copy/discard #2018
Merged
Merged
Changes from all commits
Commits
Show all changes
129 commits
Select commit
Hold shift + click to select a range
937cd14
Add TypeTransformer and (Sum/Function)Type(Arg/Row)::transform
acl-cqc 815536b
trait Transformable to common up all the 'let mut any_change = false'…
acl-cqc cc1e8f2
Transformable v2: implement for [E], works without iter_mut/etc. in a…
acl-cqc 4888184
first test, fix CustomType bound caching
acl-cqc 7002e4d
Second test, fix SumType caching
acl-cqc 6cc7cea
Make clippy happy
acl-cqc d43784b
Add HugrMut::optype_mut (v2, allow mutating root if RootHandle == Node)
acl-cqc 422c496
WIP add hugr-passes/src/lower_types.rs (w/ change_node, subst_ty)
acl-cqc 76ed391
Add def_arc
acl-cqc ed5b5dd
change_node, change_type, and the rest
acl-cqc adcbbf6
Use TypeTransformer framework, removing most type_stuff from lower_ty…
acl-cqc d84ae4e
Add a load of copy/discard lowering stuff, OpReplacement
acl-cqc bfa52cf
OpHashWrapper
acl-cqc b373571
Parametrized type support
acl-cqc a8e613a
remove copy_discard stuff
acl-cqc 24ed15c
Assume less in OpReplacement::replace
acl-cqc 9153fcf
parametrized ops
acl-cqc a89879c
Comments, renaming, use const_fn
acl-cqc c78d88a
Comment const_fn TODO
acl-cqc bf6a9a4
Test panics on unexpected argument - simpler, better
acl-cqc 5ecd9e6
test functiontype
acl-cqc d9a6d29
clippy that new test
acl-cqc 83e798e
Merge remote-tracking branch 'origin/main' into acl/type_transform
acl-cqc 84fe82d
WIP setup for test
acl-cqc 6168353
First test
acl-cqc fcb85a2
read only makes sense for Copyables
acl-cqc 0f9aa17
Extend test to Calls of polyfunc; comments, monomorphize first
acl-cqc 74c6775
no, instantiate the calls with types being lowered
acl-cqc 00fd284
Consts: HashMap keyed by either, add lower_ methods. Test TailLoop an…
acl-cqc 9f02acf
clippy, turn off type-complexity
acl-cqc a0ac6d6
Actual Error for check_sig, add setter method
acl-cqc 6ac9efc
docs
acl-cqc 044ff32
Test variable, boundednat; use list_type
acl-cqc b539e2f
Yet Another ValidationLevel interface
acl-cqc 2c7e035
Merge remote-tracking branch 'origin/main' into acl/type_transform
acl-cqc 6b190a6
Merge branch 'acl/type_transform' into acl/lower_types
acl-cqc bd24d1a
clippy
acl-cqc a5d8b65
doclinxs
acl-cqc 6b1438c
pub re-export
acl-cqc d1036bc
fix const_loop for extensions
acl-cqc d19dc5a
fix other test for extensions, but turn off extension validation afte…
acl-cqc d0fddde
Add another test of Conditional + Case
acl-cqc 3494887
common up read_op
acl-cqc ffdcaf2
test tidies
acl-cqc 6f8f43c
No need to validate, run() does it for us
acl-cqc e3da259
check_sig: use Option::unzip to tuple-ize
acl-cqc 28f2470
Move private utility classes below the pub ones; add comments
acl-cqc bef90b0
Comments - all callbacks return Option
acl-cqc 85df7ff
test: Rename lower_types to lowerer
acl-cqc 507f027
Extend loop_const test
acl-cqc bae0ebe
Add copy/dup linearization stuff
acl-cqc 8fa79bd
do_copy_chain => insert_copy_discard
acl-cqc 6a186a5
Move insert_copy_discard into Linearizer
acl-cqc 6d8a89b
Add LinearizeError
acl-cqc 3f0f1e6
pass Linearizer to callbacks
acl-cqc 974a25b
comments
acl-cqc 2bbf663
first test, don't linearize root node outputs, reject nonlocal edges
acl-cqc 290a8ae
copy_fn/discard_fn return Result
acl-cqc 19b1442
linearize takes &TypeDef not TypeDef
acl-cqc 269f0f1
OpReplacement::add(&self, ...) -> add_hugr(self, ...)
acl-cqc f6a1af5
Drop an else-continue
acl-cqc ac9adac
Add OpReplacement::add for builder
acl-cqc 65eaf52
Handle Sum Types in copy_op/discard_op
acl-cqc 354a89c
drop redundant allow-missing_docs
acl-cqc 1b31631
Refactor test code, fix --all-features
acl-cqc d5cbd58
Test copying+discarding an option of two elements
acl-cqc 63bdd3b
tidy imports
acl-cqc 1ac3728
Combine lower_consts(_parametric) with lower_(parametric_)type
acl-cqc e768814
Test sig checking
acl-cqc 506570b
No, remove sig checking
acl-cqc 0958e2a
Test funky partial replace
acl-cqc 74cfdb1
common up just_elem_type
acl-cqc dc79c93
comment spacing
acl-cqc 63d24b0
RIP SignatureMismatch
acl-cqc ba63fbe
Reinstate separate lower_consts/lower_consts_parametric
acl-cqc 2c7bb80
Remove the boxes
acl-cqc 08d3227
drop comment re. validation_level
acl-cqc dedc3d5
rename module lower_types -> replace_types
acl-cqc 9993467
rename LowerTypes=>ReplaceTypes, ChangeTypeError => ReplaceTypesError
acl-cqc cc81d87
rename methods, parametric => parametrized
acl-cqc 74c6492
doc notes
acl-cqc 18316de
comment/doc updates
acl-cqc 520e414
fmt
acl-cqc 0814bf2
callbacks for Const take &ReplaceTypes
acl-cqc 0a82fef
Replace that break 'changed block with a match, + map_or_else to avoi…
acl-cqc 94c0ff3
Add Type::as_extension
acl-cqc e9ff81c
wip
acl-cqc cf6451f
add list_const handler, use in test
acl-cqc 9a355d5
Clarify replace_consts_parametrized callback
acl-cqc ec2d0ba
const callbacks report errors via Result
acl-cqc c9d7033
fmt+fix
acl-cqc 812ac89
comment tweaks
acl-cqc ae7bd6e
Merge remote-tracking branch 'origin/main' into acl/lower_types
acl-cqc e0937ee
docs
acl-cqc 36df03c
and some more - warn on missing_docs except ReplaceTypesError
acl-cqc 71f8c0b
Merge remote-tracking branch 'origin/main' into acl/lower_types
acl-cqc dc0c7dd
Merge branch 'acl/lower_types' into acl/lower_types_linearize
acl-cqc 31ba4e0
docs, make pub, more errors
acl-cqc 86c73ed
Test copyable element inside Sum - breaks test
acl-cqc 92d7a51
Error on copyable; handle copyable elements of sums - fixes
acl-cqc 582b9f1
register errors with type; panic on function as already ruled out
acl-cqc 95da97d
more docs - no overriding copy/discard of non-extension types
acl-cqc c7e56e6
pub discard_op
acl-cqc a1e63de
rm Boxes
acl-cqc 7634e92
Only allow copy/discard funcs for *Custom*Type's
acl-cqc 0cd31e0
single callback taking num_outports != 1
acl-cqc 65b8993
In insert_copy_discard, a discard really is a 0-way copy
acl-cqc 198f990
renaming
acl-cqc 517cd0d
Generalize test 2,3,4 copies
acl-cqc 272f024
Simplify test w/binary copy to just option type, add more complex w/ …
acl-cqc e74b12b
combine the two test extensions
acl-cqc 34bd90d
tweaks
acl-cqc a2cba09
filter
acl-cqc 3084004
so that
acl-cqc cec9162
insert_copy_discard takes Wire, no Type
acl-cqc bf74996
Rename OpReplacement -> NodeTemplate
acl-cqc 221bf7d
fix dataflowparent doclink
acl-cqc f6312bc
Remove linearize() proxy methods, add linearizer() getter - docs a mess
acl-cqc 5fe25c0
docs+notes
acl-cqc edd2126
fix lists in docs
acl-cqc 5ea9763
Add Linearizer trait, rename to DelegatingLinearizer
acl-cqc cc4fd68
Pass &dyn Linearizer - requires making object-safe
acl-cqc 8a1ff0c
No - revert - instead pass ref to new CallbackHandler struct
acl-cqc d5e4ac3
Add LinearizeError::WrongSignature
acl-cqc b259426
Remove NeedDiscard, rename NeedCopy
acl-cqc a14fafa
test, also check sig for register(CustTy, NodeTempl*2)
acl-cqc a4686d3
lint
doug-q 1abf1b4
docs
doug-q 7e3efcc
Rename register(=>_simple,_parametric=>_callback), docs
acl-cqc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,47 @@ | ||
#![allow(clippy::type_complexity)] | ||
#![warn(missing_docs)] | ||
//! Replace types with other types across the Hugr. | ||
//! Replace types with other types across the Hugr. See [ReplaceTypes] and [Linearizer]. | ||
//! | ||
//! Parametrized types and ops will be reparametrized taking into account the replacements, | ||
//! but any ops taking/returning the replaced types *not* as a result of parametrization, | ||
//! will also need to be replaced - see [ReplaceTypes::replace_op]. (Similarly [Const]s.) | ||
use std::borrow::Cow; | ||
use std::collections::HashMap; | ||
use std::sync::Arc; | ||
|
||
use thiserror::Error; | ||
|
||
use hugr_core::builder::{BuildError, BuildHandle, Dataflow}; | ||
use hugr_core::extension::{ExtensionId, OpDef, SignatureError, TypeDef}; | ||
use hugr_core::hugr::hugrmut::HugrMut; | ||
use hugr_core::ops::constant::{OpaqueValue, Sum}; | ||
use hugr_core::ops::handle::DataflowOpID; | ||
use hugr_core::ops::{ | ||
AliasDefn, Call, CallIndirect, Case, Conditional, Const, DataflowBlock, ExitBlock, ExtensionOp, | ||
FuncDecl, FuncDefn, Input, LoadConstant, LoadFunction, OpType, Output, Tag, TailLoop, Value, | ||
CFG, DFG, | ||
FuncDecl, FuncDefn, Input, LoadConstant, LoadFunction, OpTrait, OpType, Output, Tag, TailLoop, | ||
Value, CFG, DFG, | ||
}; | ||
use hugr_core::types::{CustomType, Transformable, Type, TypeArg, TypeEnum, TypeTransformer}; | ||
use hugr_core::{Hugr, Node}; | ||
use hugr_core::types::{ | ||
CustomType, Signature, Transformable, Type, TypeArg, TypeEnum, TypeTransformer, | ||
}; | ||
use hugr_core::{Hugr, HugrView, Node, Wire}; | ||
|
||
use crate::validation::{ValidatePassError, ValidationLevel}; | ||
|
||
/// A thing with which an Op (i.e. node) can be replaced | ||
mod linearize; | ||
pub use linearize::{CallbackHandler, DelegatingLinearizer, LinearizeError, Linearizer}; | ||
|
||
/// A recipe for creating a dataflow Node - as a new child of a [DataflowParent] | ||
/// or in order to replace an existing node. | ||
/// | ||
/// [DataflowParent]: hugr_core::ops::OpTag::DataflowParent | ||
#[derive(Clone, Debug, PartialEq)] | ||
pub enum OpReplacement { | ||
/// Keep the same node, change only the op (updating types of inputs/outputs) | ||
pub enum NodeTemplate { | ||
/// A single node - so if replacing an existing node, change only the op | ||
SingleOp(OpType), | ||
/// Defines a sub-Hugr to splice in place of the op - a [CFG], [Conditional], [DFG] | ||
/// or [TailLoop], which must have the same inputs and outputs as the original op, | ||
/// modulo replacement. | ||
/// Defines a sub-Hugr to insert, whose root becomes (or replaces) the desired Node. | ||
/// The root must be a [CFG], [Conditional], [DFG] or [TailLoop]. | ||
// Not a FuncDefn, nor Case/DataflowBlock | ||
/// Note this will be of limited use before [monomorphization](super::monomorphize()) because | ||
/// the sub-Hugr will not be able to use type variables present in the op. | ||
/// Note this will be of limited use before [monomorphization](super::monomorphize()) | ||
/// because the new subtree will not be able to use type variables present in the | ||
/// parent Hugr or previous op. | ||
// TODO: store also a vec<TypeParam>, and update Hugr::validate to take &[TypeParam]s | ||
// (defaulting to empty list) - see https://github.com/CQCL/hugr/issues/709 | ||
CompoundOp(Box<Hugr>), | ||
|
@@ -42,12 +50,33 @@ pub enum OpReplacement { | |
// So client should add the functions before replacement, then remove unused ones afterwards.) | ||
} | ||
|
||
impl OpReplacement { | ||
impl NodeTemplate { | ||
/// Adds this instance to the specified [HugrMut] as a new node or subtree under a | ||
/// given parent, returning the unique new child (of that parent) thus created | ||
pub fn add_hugr(self, hugr: &mut impl HugrMut, parent: Node) -> Node { | ||
match self { | ||
NodeTemplate::SingleOp(op_type) => hugr.add_node_with_parent(parent, op_type), | ||
NodeTemplate::CompoundOp(new_h) => hugr.insert_hugr(parent, *new_h).new_root, | ||
} | ||
} | ||
|
||
/// Adds this instance to the specified [Dataflow] builder as a new node or subtree | ||
pub fn add( | ||
self, | ||
dfb: &mut impl Dataflow, | ||
inputs: impl IntoIterator<Item = Wire>, | ||
) -> Result<BuildHandle<DataflowOpID>, BuildError> { | ||
match self { | ||
NodeTemplate::SingleOp(opty) => dfb.add_dataflow_op(opty, inputs), | ||
NodeTemplate::CompoundOp(h) => dfb.add_hugr_with_wires(*h, inputs), | ||
} | ||
} | ||
|
||
fn replace(&self, hugr: &mut impl HugrMut, n: Node) { | ||
assert_eq!(hugr.children(n).count(), 0); | ||
let new_optype = match self.clone() { | ||
OpReplacement::SingleOp(op_type) => op_type, | ||
OpReplacement::CompoundOp(new_h) => { | ||
NodeTemplate::SingleOp(op_type) => op_type, | ||
NodeTemplate::CompoundOp(new_h) => { | ||
let new_root = hugr.insert_hugr(n, *new_h).new_root; | ||
let children = hugr.children(new_root).collect::<Vec<_>>(); | ||
let root_opty = hugr.remove_node(new_root); | ||
|
@@ -59,16 +88,50 @@ impl OpReplacement { | |
}; | ||
*hugr.optype_mut(n) = new_optype; | ||
} | ||
|
||
fn signature(&self) -> Option<Cow<'_, Signature>> { | ||
match self { | ||
NodeTemplate::SingleOp(op_type) => op_type, | ||
NodeTemplate::CompoundOp(hugr) => hugr.root_type(), | ||
} | ||
.dataflow_signature() | ||
} | ||
} | ||
|
||
/// A configuration of what types, ops, and constants should be replaced with what. | ||
/// May be applied to a Hugr via [Self::run]. | ||
/// | ||
/// Parametrized types and ops will be reparametrized taking into account the | ||
/// replacements, but any ops taking/returning the replaced types *not* as a result of | ||
/// parametrization, will also need to be replaced - see [Self::replace_op]. | ||
/// Similarly [Const]s. | ||
/// | ||
/// Types that are [Copyable](hugr_core::types::TypeBound::Copyable) may also be replaced | ||
/// with types that are not, see [Linearizer]. | ||
/// | ||
/// Note that although this pass may be used before [monomorphization], there are some | ||
/// limitations (that do not apply if done after [monomorphization]): | ||
/// * [NodeTemplate::CompoundOp] only works for operations that do not use type variables | ||
/// * "Overrides" of specific instantiations of polymorphic types will not be detected if | ||
/// the instantiations are created inside polymorphic functions. For example, suppose | ||
/// we [Self::replace_type] type `A` with `X`, [Self::replace_parametrized_type] | ||
/// container `MyList` with `List`, and [Self::replace_type] `MyList<A>` with | ||
/// `SpecialListOfXs`. If a function `foo` polymorphic over a type variable `T` dealing | ||
/// with `MyList<T>`s, that is called with type argument `A`, then `foo<T>` will be | ||
/// updated to deal with `List<T>`s and the call `foo<A>` updated to `foo<X>`, but this | ||
/// will still result in using `List<X>` rather than `SpecialListOfXs`. (However this | ||
/// would be fine *after* [monomorphization]: the monomorphic definition of `foo_A` | ||
/// would use `SpecialListOfXs`.) | ||
/// * See also limitations noted for [Linearizer]. | ||
/// | ||
/// [monomorphization]: super::monomorphize() | ||
#[derive(Clone, Default)] | ||
pub struct ReplaceTypes { | ||
type_map: HashMap<CustomType, Type>, | ||
param_types: HashMap<ParametricType, Arc<dyn Fn(&[TypeArg]) -> Option<Type>>>, | ||
op_map: HashMap<OpHashWrapper, OpReplacement>, | ||
param_ops: HashMap<ParametricOp, Arc<dyn Fn(&[TypeArg]) -> Option<OpReplacement>>>, | ||
linearize: DelegatingLinearizer, | ||
op_map: HashMap<OpHashWrapper, NodeTemplate>, | ||
param_ops: HashMap<ParametricOp, Arc<dyn Fn(&[TypeArg]) -> Option<NodeTemplate>>>, | ||
consts: HashMap< | ||
CustomType, | ||
Arc<dyn Fn(&OpaqueValue, &ReplaceTypes) -> Result<Value, ReplaceTypesError>>, | ||
|
@@ -109,6 +172,8 @@ pub enum ReplaceTypesError { | |
SignatureError(#[from] SignatureError), | ||
#[error(transparent)] | ||
ValidationError(#[from] ValidatePassError), | ||
#[error(transparent)] | ||
LinearizeError(#[from] LinearizeError), | ||
} | ||
|
||
impl ReplaceTypes { | ||
|
@@ -157,16 +222,33 @@ impl ReplaceTypes { | |
// (depending on arguments - i.e. if src's TypeDefBound is anything other than | ||
// `TypeDefBound::Explicit(TypeBound::Copyable)`) but that seems an annoying | ||
// overapproximation. Moreover, these depend upon the *return type* of the Fn. | ||
// It would be too awkward to require: | ||
// dest_fn: impl Fn(&TypeArg) -> (Type, | ||
// Fn(&Linearizer) -> NodeTemplate, // copy | ||
// Fn(&Linearizer) -> NodeTemplate)` // discard | ||
self.param_types.insert(src.into(), Arc::new(dest_fn)); | ||
} | ||
|
||
/// Allows to configure how to deal with types/wires that were [Copyable] | ||
/// but have become linear as a result of type-changing. Specifically, | ||
/// the [Linearizer] is used whenever lowering produces an outport which both | ||
/// * has a non-[Copyable] type - perhaps a direct substitution, or perhaps e.g. | ||
/// as a result of changing the element type of a collection such as an [`array`] | ||
/// * has other than one connected inport, | ||
/// | ||
/// [Copyable]: hugr_core::types::TypeBound::Copyable | ||
/// [`array`]: hugr_core::std_extensions::collections::array::array_type | ||
pub fn linearizer(&mut self) -> &mut DelegatingLinearizer { | ||
&mut self.linearize | ||
} | ||
|
||
/// Configures this instance to change occurrences of `src` to `dest`. | ||
/// Note that if `src` is an instance of a *parametrized* [OpDef], this takes | ||
/// precedence over [Self::replace_parametrized_op] where the `src`s overlap. Thus, | ||
/// this should only be used on already-*[monomorphize](super::monomorphize())d* | ||
/// Hugrs, as substitution (parametric polymorphism) happening later will not respect | ||
/// this replacement. | ||
pub fn replace_op(&mut self, src: &ExtensionOp, dest: OpReplacement) { | ||
pub fn replace_op(&mut self, src: &ExtensionOp, dest: NodeTemplate) { | ||
self.op_map.insert(OpHashWrapper::from(src), dest); | ||
} | ||
|
||
|
@@ -179,7 +261,7 @@ impl ReplaceTypes { | |
pub fn replace_parametrized_op( | ||
&mut self, | ||
src: &OpDef, | ||
dest_fn: impl Fn(&[TypeArg]) -> Option<OpReplacement> + 'static, | ||
dest_fn: impl Fn(&[TypeArg]) -> Option<NodeTemplate> + 'static, | ||
) { | ||
self.param_ops.insert(src.into(), Arc::new(dest_fn)); | ||
} | ||
|
@@ -221,6 +303,22 @@ impl ReplaceTypes { | |
let mut changed = false; | ||
for n in hugr.nodes().collect::<Vec<_>>() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. collect_vec can be used here |
||
changed |= self.change_node(hugr, n)?; | ||
let new_dfsig = hugr.get_optype(n).dataflow_signature(); | ||
if let Some(new_sig) = new_dfsig | ||
.filter(|_| changed && n != hugr.root()) | ||
.map(Cow::into_owned) | ||
{ | ||
for outp in new_sig.output_ports() { | ||
if !new_sig.out_port_type(outp).unwrap().copyable() { | ||
let targets = hugr.linked_inputs(n, outp).collect::<Vec<_>>(); | ||
if targets.len() != 1 { | ||
hugr.disconnect(n, outp); | ||
let src = Wire::new(n, outp); | ||
self.linearize.insert_copy_discard(hugr, src, &targets)?; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
Ok(changed) | ||
} | ||
|
@@ -452,7 +550,7 @@ mod test { | |
use hugr_core::{hugr::IdentList, type_row, Extension, HugrView}; | ||
use itertools::Itertools; | ||
|
||
use super::{handlers::list_const, OpReplacement, ReplaceTypes}; | ||
use super::{handlers::list_const, NodeTemplate, ReplaceTypes}; | ||
|
||
const PACKED_VEC: &str = "PackedVec"; | ||
const READ: &str = "read"; | ||
|
@@ -513,7 +611,7 @@ mod test { | |
} | ||
|
||
fn lowerer(ext: &Arc<Extension>) -> ReplaceTypes { | ||
fn lowered_read(args: &[TypeArg]) -> Option<OpReplacement> { | ||
fn lowered_read(args: &[TypeArg]) -> Option<NodeTemplate> { | ||
let ty = just_elem_type(args); | ||
let mut dfb = DFGBuilder::new(inout_sig( | ||
vec![array_type(64, ty.clone()), i64_t()], | ||
|
@@ -532,7 +630,7 @@ mod test { | |
let [res] = dfb | ||
.build_unwrap_sum(1, option_type(Type::from(ty.clone())), opt) | ||
.unwrap(); | ||
Some(OpReplacement::CompoundOp(Box::new( | ||
Some(NodeTemplate::CompoundOp(Box::new( | ||
dfb.finish_hugr_with_outputs([res]).unwrap(), | ||
))) | ||
} | ||
|
@@ -545,7 +643,7 @@ mod test { | |
); | ||
lw.replace_op( | ||
&read_op(ext, bool_t()), | ||
OpReplacement::SingleOp( | ||
NodeTemplate::SingleOp( | ||
ExtensionOp::new(ext.get_op("lowered_read_bool").unwrap().clone(), []) | ||
.unwrap() | ||
.into(), | ||
|
@@ -824,7 +922,7 @@ mod test { | |
e.get_op(READ).unwrap().as_ref(), | ||
Box::new(|args: &[TypeArg]| { | ||
option_contents(just_elem_type(args)).map(|elem| { | ||
OpReplacement::SingleOp( | ||
NodeTemplate::SingleOp( | ||
ListOp::get | ||
.with_type(elem) | ||
.to_extension_op() | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These two are pub because other extensions may want them for defining their own copy/discard handlers (that build nested Hugrs that copy elements of collections, etc.)