From 3f4af2defee4bcffbd02e979d15acb8574a1bd34 Mon Sep 17 00:00:00 2001 From: Alan Lawrence Date: Fri, 10 May 2024 11:00:57 +0100 Subject: [PATCH] Rm singly-impl'd TypeParametrised, rm Concrete --- hugr/src/extension.rs | 12 ------------ hugr/src/extension/declarative/signature.rs | 2 +- hugr/src/extension/declarative/types.rs | 2 +- hugr/src/extension/type_def.rs | 10 ++++------ 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/hugr/src/extension.rs b/hugr/src/extension.rs index 4c4d27ea2..69e0f1ab5 100644 --- a/hugr/src/extension.rs +++ b/hugr/src/extension.rs @@ -232,18 +232,6 @@ impl CustomConcrete for CustomType { } } -/// Type-parametrised functionality shared between [`TypeDef`] and [`OpDef`]. -trait TypeParametrised { - /// The concrete object built by binding type arguments to parameters - type Concrete: CustomConcrete; - /// The extension-unique name. - fn name(&self) -> &::Identifier; - /// Type parameters. - fn params(&self) -> &[TypeParam]; - /// The parent extension. - fn extension(&self) -> &ExtensionId; -} - /// A constant value provided by a extension. /// Must be an instance of a type available to the extension. #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] diff --git a/hugr/src/extension/declarative/signature.rs b/hugr/src/extension/declarative/signature.rs index a1c6befba..df1aaab3b 100644 --- a/hugr/src/extension/declarative/signature.rs +++ b/hugr/src/extension/declarative/signature.rs @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize}; use smol_str::SmolStr; use crate::extension::prelude::PRELUDE_ID; -use crate::extension::{CustomValidator, ExtensionSet, SignatureFunc, TypeDef, TypeParametrised}; +use crate::extension::{CustomValidator, ExtensionSet, SignatureFunc, TypeDef}; use crate::types::type_param::TypeParam; use crate::types::{CustomType, FunctionType, PolyFuncType, Type, TypeRow}; use crate::Extension; diff --git a/hugr/src/extension/declarative/types.rs b/hugr/src/extension/declarative/types.rs index c90eb08e7..fb624b6f7 100644 --- a/hugr/src/extension/declarative/types.rs +++ b/hugr/src/extension/declarative/types.rs @@ -7,7 +7,7 @@ //! [specification]: https://github.com/CQCL/hugr/blob/main/specification/hugr.md#declarative-format //! [`ExtensionSetDeclaration`]: super::ExtensionSetDeclaration -use crate::extension::{TypeDef, TypeDefBound, TypeParametrised}; +use crate::extension::{TypeDef, TypeDefBound}; use crate::types::type_param::TypeParam; use crate::types::{CustomType, TypeBound, TypeName}; use crate::Extension; diff --git a/hugr/src/extension/type_def.rs b/hugr/src/extension/type_def.rs index 950251843..5ca9e2f7c 100644 --- a/hugr/src/extension/type_def.rs +++ b/hugr/src/extension/type_def.rs @@ -1,7 +1,7 @@ use std::collections::hash_map::Entry; use super::{CustomConcrete, ExtensionBuildError}; -use super::{Extension, ExtensionId, SignatureError, TypeParametrised}; +use super::{Extension, ExtensionId, SignatureError}; use crate::types::{least_upper_bound, CustomType, TypeName}; @@ -122,12 +122,10 @@ impl TypeDef { } } } -} - -impl TypeParametrised for TypeDef { - type Concrete = CustomType; - fn params(&self) -> &[TypeParam] { + /// The static parameters to the TypeDef; a [TypeArg] appropriate for each + /// must be provided to produce an actual type. + pub fn params(&self) -> &[TypeParam] { &self.params }