Skip to content

Commit

Permalink
Update PolyFuncType-vs-FunctionType docs, in rust+py, regenerate schema
Browse files Browse the repository at this point in the history
  • Loading branch information
acl-cqc committed Apr 9, 2024
1 parent b070a5f commit 1777329
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions hugr-py/src/hugr/serialization/tys.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ class Config:


class PolyFuncType(BaseModel):
"""A graph encoded as a value. It contains a concrete signature and a set of
required resources."""
"""A polymorphic type scheme, i.e. of a FuncDecl, FuncDefn or OpDef.
(Nodes/operations in the Hugr are not polymorphic.)"""

# The declared type parameters, i.e., these must be instantiated with the same
# number of TypeArgs before the function can be called. This defines the indices
Expand All @@ -230,8 +230,8 @@ class Config:
# Needed to avoid random '\n's in the pydantic description
json_schema_extra = {
"description": (
"A graph encoded as a value. It contains a concrete signature and "
"a set of required resources."
"A polymorphic type scheme, i.e. of a FuncDecl, FuncDefn or OpDef. "
"(Nodes/operations in the Hugr are not polymorphic.)"
)
}

Expand Down
5 changes: 3 additions & 2 deletions hugr/src/types/poly_func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ use itertools::Itertools;
use super::type_param::{check_type_args, TypeArg, TypeParam};
use super::{FunctionType, Substitution};

/// A polymorphic function type, e.g. of a [Graph], or perhaps an [OpDef].
/// A polymorphic type scheme, i.e. of a [FuncDecl], [FuncDefn] or [OpDef].
/// (Nodes/operations in the Hugr are not polymorphic.)
///
/// [Graph]: crate::ops::constant::Const::Function
/// [FuncDecl]: crate::ops::module::FuncDecl
/// [FuncDefn]: crate::ops::module::FuncDefn
/// [OpDef]: crate::extension::OpDef
#[derive(
Clone, PartialEq, Debug, Default, Eq, derive_more::Display, serde::Serialize, serde::Deserialize,
Expand Down
5 changes: 4 additions & 1 deletion hugr/src/types/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ use crate::extension::{ExtensionRegistry, ExtensionSet, SignatureError};
use crate::{Direction, IncomingPort, OutgoingPort, Port};

#[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
/// Describes the edges required to/from a node. This includes both the concept of "signature" in the spec,
/// Describes the edges required to/from a node, and thus, also the type of a [Graph].
/// This includes both the concept of "signature" in the spec,
/// and also the target (value) of a call (static).
///
/// [Graph]: crate::ops::constant::Const::Function
pub struct FunctionType {
/// Value inputs of the function.
pub input: TypeRow,
Expand Down
2 changes: 1 addition & 1 deletion specification/hugr.md
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ However, for OpDef's, greater flexibility is allowed: each OpDef *either*
`compute_signature` that fallibly computes a (perhaps-polymorphic) type scheme given some initial type arguments.
The operation declares the arguments required by the `compute_signature` function as a list
of TypeParams; if this successfully returns a type scheme, that may have additional TypeParams
for which TypeArgs must also be provided.
for which TypeArgs must also be provided.

For example, the TypeDef for `array` in the prelude declares two TypeParams: a `BoundedUSize`
(the array length) and a `Type`. Any valid instantiation (e.g. `array<5, usize>`) is a type.
Expand Down
2 changes: 1 addition & 1 deletion specification/schema/hugr_schema_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@
"type": "object"
},
"PolyFuncType": {
"description": "A graph encoded as a value. It contains a concrete signature and a set of required resources.",
"description": "A polymorphic type scheme, i.e. of a FuncDecl, FuncDefn or OpDef. (Nodes/operations in the Hugr are not polymorphic.)",
"properties": {
"params": {
"items": {
Expand Down

0 comments on commit 1777329

Please sign in to comment.