Skip to content

Commit 4a40b9b

Browse files
committed
FunctionTypeRV -> FuncValueType
1 parent eb3e86c commit 4a40b9b

File tree

16 files changed

+61
-63
lines changed

16 files changed

+61
-63
lines changed

hugr-core/src/builder/dataflow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pub(crate) mod test {
212212

213213
use crate::std_extensions::logic::test::and_op;
214214
use crate::types::type_param::TypeParam;
215-
use crate::types::{FunctionType, FunctionTypeRV, Type, TypeBound, TypeRV};
215+
use crate::types::{FuncValueType, FunctionType, Type, TypeBound, TypeRV};
216216
use crate::utils::test_quantum_extension::h_gate;
217217
use crate::{
218218
builder::test::{n_identity, BIT, NAT, QB},
@@ -530,7 +530,7 @@ pub(crate) mod test {
530530
PolyFuncType::new(
531531
[TypeParam::new_list(TypeBound::Copyable)],
532532
FunctionType::new(
533-
Type::new_function(FunctionTypeRV::new(USIZE_T, tv.clone())),
533+
Type::new_function(FuncValueType::new(USIZE_T, tv.clone())),
534534
vec![],
535535
),
536536
),

hugr-core/src/extension/declarative/signature.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use smol_str::SmolStr;
1414
use crate::extension::prelude::PRELUDE_ID;
1515
use crate::extension::{ExtensionSet, SignatureFunc, TypeDef};
1616
use crate::types::type_param::TypeParam;
17-
use crate::types::{CustomType, FunctionTypeRV, PolyFuncTypeRV, Type, TypeRowRV};
17+
use crate::types::{CustomType, FuncValueType, PolyFuncTypeRV, Type, TypeRowRV};
1818
use crate::Extension;
1919

2020
use super::{DeclarationContext, ExtensionDeclarationError};
@@ -50,7 +50,7 @@ impl SignatureDeclaration {
5050
Ok(types.into())
5151
};
5252

53-
let body = FunctionTypeRV {
53+
let body = FuncValueType {
5454
input: make_type_row(&self.inputs)?,
5555
output: make_type_row(&self.outputs)?,
5656
extension_reqs: self.extensions.clone(),

hugr-core/src/extension/op_def.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use super::{
1111

1212
use crate::ops::{OpName, OpNameRef};
1313
use crate::types::type_param::{check_type_args, TypeArg, TypeParam};
14-
use crate::types::{FunctionType, FunctionTypeRV, PolyFuncTypeRV};
14+
use crate::types::{FuncValueType, FunctionType, PolyFuncTypeRV};
1515
use crate::Hugr;
1616

1717
/// Trait necessary for binary computations of OpDef signature
@@ -192,15 +192,15 @@ impl From<PolyFuncTypeRV> for SignatureFunc {
192192
}
193193
}
194194

195-
impl From<FunctionTypeRV> for SignatureFunc {
196-
fn from(v: FunctionTypeRV) -> Self {
195+
impl From<FuncValueType> for SignatureFunc {
196+
fn from(v: FuncValueType) -> Self {
197197
Self::PolyFuncType(CustomValidator::from_polyfunc(v))
198198
}
199199
}
200200

201201
impl From<FunctionType> for SignatureFunc {
202202
fn from(v: FunctionType) -> Self {
203-
Self::PolyFuncType(CustomValidator::from_polyfunc(FunctionTypeRV::from(v)))
203+
Self::PolyFuncType(CustomValidator::from_polyfunc(FuncValueType::from(v)))
204204
}
205205
}
206206

hugr-core/src/extension/prelude.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use lazy_static::lazy_static;
44

55
use crate::ops::constant::{CustomCheckFailure, ValueName};
66
use crate::ops::{CustomOp, OpName};
7-
use crate::types::{FunctionTypeRV, SumType, TypeName};
7+
use crate::types::{FuncValueType, SumType, TypeName};
88
use crate::{
99
extension::{ExtensionId, TypeDefBound},
1010
ops::constant::CustomConst,
@@ -32,7 +32,7 @@ impl SignatureFromArgs for ArrayOpCustom {
3232

3333
Ok(PolyFuncTypeRV::new(
3434
vec![TypeBound::Any.into()],
35-
FunctionTypeRV::new(var_arg_row, other_row),
35+
FuncValueType::new(var_arg_row, other_row),
3636
))
3737
}
3838

@@ -67,7 +67,7 @@ impl SignatureFromArgs for GenericOpCustom {
6767
};
6868
outs.push(ty.clone());
6969
}
70-
Ok(FunctionTypeRV::new(inps, outs).into())
70+
Ok(FuncValueType::new(inps, outs).into())
7171
}
7272

7373
fn static_params(&self) -> &[TypeParam] {

hugr-core/src/hugr/serialize/test.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::std_extensions::arithmetic::int_types::{int_custom_type, ConstInt, IN
1515
use crate::std_extensions::logic::NotOp;
1616
use crate::types::type_param::TypeParam;
1717
use crate::types::{
18-
FunctionType, FunctionTypeRV, PolyFuncType, PolyFuncTypeRV, SumType, Type, TypeArg, TypeBound,
18+
FuncValueType, FunctionType, PolyFuncType, PolyFuncTypeRV, SumType, Type, TypeArg, TypeBound,
1919
TypeRV,
2020
};
2121
use crate::{type_row, OutgoingPort};
@@ -440,10 +440,10 @@ fn polyfunctype2() -> PolyFuncTypeRV {
440440
let tv1 = TypeRV::new_row_var_use(1, TypeBound::Eq);
441441
let params = [TypeBound::Any, TypeBound::Eq].map(TypeParam::new_list);
442442
let inputs = vec![
443-
TypeRV::new_function(FunctionTypeRV::new(tv0.clone(), tv1.clone())),
443+
TypeRV::new_function(FuncValueType::new(tv0.clone(), tv1.clone())),
444444
tv0,
445445
];
446-
let res = PolyFuncTypeRV::new(params, FunctionTypeRV::new(inputs, tv1));
446+
let res = PolyFuncTypeRV::new(params, FuncValueType::new(inputs, tv1));
447447
// Just check we've got the arguments the right way round
448448
// (not that it really matters for the serialization schema we have)
449449
res.validate(&EMPTY_REG).unwrap();
@@ -465,14 +465,14 @@ fn roundtrip_polyfunctype_fixedlen(#[case] poly_func_type: PolyFuncType) {
465465
}
466466

467467
#[rstest]
468-
#[case(FunctionTypeRV::new_endo(type_row![]).into())]
468+
#[case(FuncValueType::new_endo(type_row![]).into())]
469469
#[case(PolyFuncTypeRV::new([TypeParam::Opaque { ty: int_custom_type(TypeArg::BoundedNat { n: 1 }) }], FunctionType::new_endo(type_row![Type::new_var_use(0, TypeBound::Copyable)])))]
470470
#[case(PolyFuncTypeRV::new([TypeBound::Eq.into()], FunctionType::new_endo(type_row![Type::new_var_use(0, TypeBound::Eq)])))]
471471
#[case(PolyFuncTypeRV::new([TypeParam::new_list(TypeBound::Any)], FunctionType::new_endo(type_row![])))]
472472
#[case(PolyFuncTypeRV::new([TypeParam::Tuple { params: [TypeBound::Any.into(), TypeParam::bounded_nat(2.try_into().unwrap())].into() }], FunctionType::new_endo(type_row![])))]
473473
#[case(PolyFuncTypeRV::new(
474474
[TypeParam::new_list(TypeBound::Any)],
475-
FunctionTypeRV::new_endo(TypeRV::new_row_var_use(0, TypeBound::Any))))]
475+
FuncValueType::new_endo(TypeRV::new_row_var_use(0, TypeBound::Any))))]
476476
#[case(polyfunctype2())]
477477
fn roundtrip_polyfunctype_varlen(#[case] poly_func_type: PolyFuncTypeRV) {
478478
check_testing_roundtrip(poly_func_type)

hugr-core/src/hugr/validate/test.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use crate::std_extensions::logic::test::{and_op, or_op};
2121
use crate::std_extensions::logic::{self, NotOp};
2222
use crate::types::type_param::{TypeArg, TypeArgError};
2323
use crate::types::{
24-
CustomType, FunctionType, FunctionTypeRV, PolyFuncType, PolyFuncTypeRV, Type, TypeBound,
25-
TypeRV, TypeRow,
24+
CustomType, FuncValueType, FunctionType, PolyFuncType, PolyFuncTypeRV, Type, TypeBound, TypeRV,
25+
TypeRow,
2626
};
2727
use crate::{const_extension_ids, test_file, type_row, Direction, IncomingPort, Node};
2828

@@ -579,10 +579,10 @@ pub(crate) fn extension_with_eval_parallel() -> Extension {
579579

580580
let inputs = TypeRV::new_row_var_use(0, TypeBound::Any);
581581
let outputs = TypeRV::new_row_var_use(1, TypeBound::Any);
582-
let evaled_fn = TypeRV::new_function(FunctionTypeRV::new(inputs.clone(), outputs.clone()));
582+
let evaled_fn = TypeRV::new_function(FuncValueType::new(inputs.clone(), outputs.clone()));
583583
let pf = PolyFuncTypeRV::new(
584584
[rowp.clone(), rowp.clone()],
585-
FunctionTypeRV::new(vec![evaled_fn, inputs], outputs),
585+
FuncValueType::new(vec![evaled_fn, inputs], outputs),
586586
);
587587
e.add_op("eval".into(), "".into(), pf).unwrap();
588588

@@ -591,10 +591,10 @@ pub(crate) fn extension_with_eval_parallel() -> Extension {
591591
[rowp.clone(), rowp.clone(), rowp.clone(), rowp.clone()],
592592
FunctionType::new(
593593
vec![
594-
Type::new_function(FunctionTypeRV::new(rv(0), rv(2))),
595-
Type::new_function(FunctionTypeRV::new(rv(1), rv(3))),
594+
Type::new_function(FuncValueType::new(rv(0), rv(2))),
595+
Type::new_function(FuncValueType::new(rv(1), rv(3))),
596596
],
597-
Type::new_function(FunctionTypeRV::new(vec![rv(0), rv(1)], vec![rv(2), rv(3)])),
597+
Type::new_function(FuncValueType::new(vec![rv(0), rv(1)], vec![rv(2), rv(3)])),
598598
),
599599
);
600600
e.add_op("parallel".into(), "".into(), pf).unwrap();
@@ -644,8 +644,8 @@ fn seq1ty(t: TypeRV) -> TypeArg {
644644
fn row_variables() -> Result<(), Box<dyn std::error::Error>> {
645645
let e = extension_with_eval_parallel();
646646
let tv = TypeRV::new_row_var_use(0, TypeBound::Any);
647-
let inner_ft = Type::new_function(FunctionTypeRV::new_endo(tv.clone()));
648-
let ft_usz = Type::new_function(FunctionTypeRV::new_endo(vec![tv.clone(), USIZE_T.into()]));
647+
let inner_ft = Type::new_function(FuncValueType::new_endo(tv.clone()));
648+
let ft_usz = Type::new_function(FuncValueType::new_endo(vec![tv.clone(), USIZE_T.into()]));
649649
let mut fb = FunctionBuilder::new(
650650
"id",
651651
PolyFuncType::new(

hugr-core/src/std_extensions/arithmetic/conversions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
},
1313
ops::{custom::ExtensionOp, NamedOp},
1414
type_row,
15-
types::{FunctionTypeRV, PolyFuncTypeRV, TypeArg, TypeRV},
15+
types::{FuncValueType, PolyFuncTypeRV, TypeArg, TypeRV},
1616
Extension,
1717
};
1818

@@ -48,12 +48,12 @@ impl MakeOpDef for ConvertOpDef {
4848
PolyFuncTypeRV::new(
4949
vec![LOG_WIDTH_TYPE_PARAM],
5050
match self {
51-
trunc_s | trunc_u => FunctionTypeRV::new(
51+
trunc_s | trunc_u => FuncValueType::new(
5252
type_row![FLOAT64_TYPE],
5353
TypeRV::from(sum_with_error(int_tv(0))),
5454
),
5555
convert_s | convert_u => {
56-
FunctionTypeRV::new(vec![int_tv(0)], type_row![FLOAT64_TYPE])
56+
FuncValueType::new(vec![int_tv(0)], type_row![FLOAT64_TYPE])
5757
}
5858
},
5959
)

hugr-core/src/std_extensions/arithmetic/int_ops.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::ops::custom::ExtensionOp;
1010
use crate::ops::{NamedOp, OpName};
1111
use crate::std_extensions::arithmetic::int_types::int_type;
1212
use crate::type_row;
13-
use crate::types::{FunctionTypeRV, PolyFuncTypeRV, TypeRowRV};
13+
use crate::types::{FuncValueType, PolyFuncTypeRV, TypeRowRV};
1414
use crate::utils::collect_array;
1515

1616
use crate::{
@@ -162,7 +162,7 @@ impl MakeOpDef for IntOpDef {
162162
}
163163
itostring_u | itostring_s => PolyFuncTypeRV::new(
164164
vec![LOG_WIDTH_TYPE_PARAM],
165-
FunctionTypeRV::new(vec![int_tv(0)], vec![STRING_TYPE]),
165+
FuncValueType::new(vec![int_tv(0)], vec![STRING_TYPE]),
166166
)
167167
.into(),
168168
}
@@ -241,7 +241,7 @@ fn int_polytype(
241241
) -> PolyFuncTypeRV {
242242
PolyFuncTypeRV::new(
243243
vec![LOG_WIDTH_TYPE_PARAM; n_vars],
244-
FunctionTypeRV::new(input, output),
244+
FuncValueType::new(input, output),
245245
)
246246
}
247247

hugr-core/src/std_extensions/collections.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{
1717
ops::{self, custom::ExtensionOp, NamedOp},
1818
types::{
1919
type_param::{TypeArg, TypeParam},
20-
CustomCheckFailure, CustomType, FunctionTypeRV, PolyFuncTypeRV, Type, TypeBound,
20+
CustomCheckFailure, CustomType, FuncValueType, PolyFuncTypeRV, Type, TypeBound,
2121
},
2222
utils::sorted_consts,
2323
Extension,
@@ -157,7 +157,7 @@ fn extension() -> Extension {
157157
"Pop from back of list".into(),
158158
PolyFuncTypeRV::new(
159159
vec![TP],
160-
FunctionTypeRV::new(vec![l.clone()], vec![l.clone(), e.clone()]),
160+
FuncValueType::new(vec![l.clone()], vec![l.clone(), e.clone()]),
161161
),
162162
)
163163
.unwrap()
@@ -166,7 +166,7 @@ fn extension() -> Extension {
166166
.add_op(
167167
PUSH_NAME,
168168
"Push to back of list".into(),
169-
PolyFuncTypeRV::new(vec![TP], FunctionTypeRV::new(vec![l.clone(), e], vec![l])),
169+
PolyFuncTypeRV::new(vec![TP], FuncValueType::new(vec![l.clone(), e], vec![l])),
170170
)
171171
.unwrap()
172172
.set_constant_folder(PushFold);

hugr-core/src/std_extensions/logic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use strum_macros::{EnumIter, EnumString, IntoStaticStr};
55
use crate::extension::{ConstFold, ConstFoldResult};
66
use crate::ops::constant::ValueName;
77
use crate::ops::{OpName, Value};
8-
use crate::types::{FunctionType, FunctionTypeRV};
8+
use crate::types::{FuncValueType, FunctionType};
99
use crate::{
1010
extension::{
1111
prelude::BOOL_T,
@@ -168,7 +168,7 @@ fn logic_op_sig() -> impl SignatureFromArgs {
168168
return Err(SignatureError::InvalidTypeArgs);
169169
};
170170
let var_arg_row = vec![BOOL_T; n as usize];
171-
Ok(FunctionTypeRV::new(var_arg_row, vec![BOOL_T]).into())
171+
Ok(FuncValueType::new(var_arg_row, vec![BOOL_T]).into())
172172
}
173173

174174
fn static_params(&self) -> &[TypeParam] {

hugr-core/src/types.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::utils::display_list_with_separator;
1717
pub use check::SumTypeError;
1818
pub use custom::CustomType;
1919
pub use poly_func::{PolyFuncType, PolyFuncTypeRV};
20-
pub use signature::{FunctionType, FunctionTypeRV};
20+
pub use signature::{FuncValueType, FunctionType};
2121
use smol_str::SmolStr;
2222
pub use type_param::TypeArg;
2323
pub use type_row::{TypeRow, TypeRowRV};
@@ -225,7 +225,7 @@ pub enum TypeEnum<RV: MaybeRV> {
225225
Alias(AliasDecl),
226226
#[allow(missing_docs)]
227227
#[display(fmt = "Function({})", "_0")]
228-
Function(Box<FunctionTypeRV>),
228+
Function(Box<FuncValueType>),
229229
// Index into TypeParams, and cache of TypeBound (checked in validation)
230230
#[allow(missing_docs)]
231231
#[display(fmt = "Variable({})", _0)]
@@ -321,7 +321,7 @@ impl<RV: MaybeRV> TypeBase<RV> {
321321
const EMPTY_TYPEROW_REF: &'static TypeRowBase<RV> = &Self::EMPTY_TYPEROW;
322322

323323
/// Initialize a new function type.
324-
pub fn new_function(fun_ty: impl Into<FunctionTypeRV>) -> Self {
324+
pub fn new_function(fun_ty: impl Into<FuncValueType>) -> Self {
325325
Self::new(TypeEnum::Function(Box::new(fun_ty.into())))
326326
}
327327

@@ -636,7 +636,7 @@ pub(crate) mod test {
636636
use crate::proptest::RecursionDepth;
637637

638638
use super::{AliasDecl, MaybeRV, TypeBase, TypeBound, TypeEnum};
639-
use crate::types::{CustomType, FunctionTypeRV, SumType, TypeRowRV};
639+
use crate::types::{CustomType, FuncValueType, SumType, TypeRowRV};
640640
use ::proptest::prelude::*;
641641

642642
impl Arbitrary for super::SumType {
@@ -663,7 +663,7 @@ pub(crate) mod test {
663663
prop_oneof![
664664
1 => any::<AliasDecl>().prop_map(TypeBase::new_alias),
665665
1 => any_with::<CustomType>(depth.into()).prop_map(TypeBase::new_extension),
666-
1 => any_with::<FunctionTypeRV>(depth).prop_map(TypeBase::new_function),
666+
1 => any_with::<FuncValueType>(depth).prop_map(TypeBase::new_function),
667667
1 => any_with::<SumType>(depth).prop_map(TypeBase::from),
668668
1 => (any::<usize>(), any::<TypeBound>()).prop_map(|(i,b)| TypeBase::new_var_use(i,b)),
669669
// proptest_derive::Arbitrary's weight attribute requires a constant,

hugr-core/src/types/poly_func.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub(crate) mod test {
155155
use crate::types::signature::FuncTypeBase;
156156
use crate::types::type_param::{TypeArg, TypeArgError, TypeParam};
157157
use crate::types::{
158-
CustomType, FunctionType, FunctionTypeRV, MaybeRV, Type, TypeBound, TypeName, TypeRV,
158+
CustomType, FuncValueType, FunctionType, MaybeRV, Type, TypeBound, TypeName, TypeRV,
159159
};
160160
use crate::Extension;
161161

@@ -392,7 +392,7 @@ pub(crate) mod test {
392392
};
393393
let e = PolyFuncTypeBase::new_validated(
394394
[decl.clone()],
395-
FunctionTypeRV::new(
395+
FuncValueType::new(
396396
vec![USIZE_T],
397397
vec![TypeRV::new_row_var_use(0, TypeBound::Copyable)],
398398
),
@@ -421,7 +421,7 @@ pub(crate) mod test {
421421
let rty = TypeRV::new_row_var_use(0, TypeBound::Any);
422422
let pf = PolyFuncTypeBase::new_validated(
423423
[TypeParam::new_list(TP_ANY)],
424-
FunctionTypeRV::new(
424+
FuncValueType::new(
425425
vec![USIZE_T.into(), rty.clone()],
426426
vec![TypeRV::new_tuple(rty)],
427427
),
@@ -456,7 +456,7 @@ pub(crate) mod test {
456456

457457
#[test]
458458
fn row_variables_inner() {
459-
let inner_fty = Type::new_function(FunctionTypeRV::new_endo(TypeRV::new_row_var_use(
459+
let inner_fty = Type::new_function(FuncValueType::new_endo(TypeRV::new_row_var_use(
460460
0,
461461
TypeBound::Copyable,
462462
)));

hugr-core/src/types/serialize.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use super::{
2-
FunctionTypeRV, MaybeRV, RowVariable, SumType, TypeArg, TypeBase, TypeBound, TypeEnum,
3-
};
1+
use super::{FuncValueType, MaybeRV, RowVariable, SumType, TypeArg, TypeBase, TypeBound, TypeEnum};
42

53
use super::custom::CustomType;
64

@@ -13,7 +11,7 @@ use crate::ops::AliasDecl;
1311
pub(super) enum SerSimpleType {
1412
Q,
1513
I,
16-
G(Box<FunctionTypeRV>),
14+
G(Box<FuncValueType>),
1715
Sum(SumType),
1816
Array { inner: Box<SerSimpleType>, len: u64 },
1917
Opaque(CustomType),

0 commit comments

Comments
 (0)