diff --git a/quantinuum-hugr/src/ops/leaf.rs b/quantinuum-hugr/src/ops/leaf.rs index a5e0e6046..07476ff7a 100644 --- a/quantinuum-hugr/src/ops/leaf.rs +++ b/quantinuum-hugr/src/ops/leaf.rs @@ -120,6 +120,21 @@ impl TypeApplication { }) } } + + /// Returns the type of the input function. + pub fn input(&self) -> &PolyFuncType { + &self.input + } + + /// Returns the args applied to the input function. + pub fn args(&self) -> &[TypeArg] { + &self.args + } + + /// Returns the type of the output function. + pub fn output(&self) -> &PolyFuncType { + &self.output + } } impl Default for LeafOp { diff --git a/quantinuum-hugr/src/types/type_param.rs b/quantinuum-hugr/src/types/type_param.rs index e10285ae3..e6d90a249 100644 --- a/quantinuum-hugr/src/types/type_param.rs +++ b/quantinuum-hugr/src/types/type_param.rs @@ -36,6 +36,11 @@ impl UpperBound { _ => false, } } + + /// Returns the value of the upper bound. + pub fn value(&self) -> &Option { + &self.0 + } } /// A *kind* of [TypeArg]. Thus, a parameter declared by a [PolyFuncType] (e.g. [OpDef]), @@ -246,6 +251,13 @@ impl TypeArg { } } +impl TypeArgVariable { + /// Return the index. + pub fn index(&self) -> usize { + self.idx + } +} + /// A serialized representation of a value of a [CustomType] /// restricted to equatable types. #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/quantinuum-hugr/src/values.rs b/quantinuum-hugr/src/values.rs index 778dffff9..cdc7058bc 100644 --- a/quantinuum-hugr/src/values.rs +++ b/quantinuum-hugr/src/values.rs @@ -206,6 +206,11 @@ impl CustomSerialized { extensions, } } + + /// Returns the inner value. + pub fn value(&self) -> &serde_yaml::Value { + &self.value + } } #[typetag::serde]