Skip to content

Commit

Permalink
No constraints in aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
zrho committed Nov 18, 2024
1 parent 719af15 commit a05ae29
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 21 deletions.
1 change: 0 additions & 1 deletion hugr-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ workspace = true
extension_inference = []
declarative = ["serde_yaml"]
model_unstable = ["hugr-model"]
default = ["model_unstable"]

[[test]]
name = "model"
Expand Down
2 changes: 0 additions & 2 deletions hugr-core/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ impl<'a> Context<'a> {
let decl = this.bump.alloc(model::AliasDecl {
name: &alias.name,
params: &[],
constraints: &[],
r#type,
});
model::Operation::DeclareAlias { decl }
Expand All @@ -282,7 +281,6 @@ impl<'a> Context<'a> {
let decl = this.bump.alloc(model::AliasDecl {
name: &alias.name,
params: &[],
constraints: &[],
r#type,
});
model::Operation::DefineAlias { decl, value }
Expand Down
8 changes: 3 additions & 5 deletions hugr-model/capnp/hugr-v0.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,14 @@ struct Operation {
struct AliasDefn {
name @0 :Text;
params @1 :List(Param);
constraints @2 :List(TermId);
type @3 :TermId;
value @4 :TermId;
type @2 :TermId;
value @3 :TermId;
}

struct AliasDecl {
name @0 :Text;
params @1 :List(Param);
constraints @2 :List(TermId);
type @3 :TermId;
type @2 :TermId;
}

struct ConstructorDecl {
Expand Down
4 changes: 0 additions & 4 deletions hugr-model/src/v0/binary/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,11 @@ fn read_operation<'a>(
let reader = reader?;
let name = bump.alloc_str(reader.get_name()?.to_str()?);
let params = read_list!(bump, reader, get_params, read_param);
let constraints = read_scalar_list!(bump, reader, get_constraints, model::TermId);
let r#type = model::TermId(reader.get_type());
let value = model::TermId(reader.get_value());
let decl = bump.alloc(model::AliasDecl {
name,
params,
constraints,
r#type,
});
model::Operation::DefineAlias { decl, value }
Expand All @@ -183,12 +181,10 @@ fn read_operation<'a>(
let reader = reader?;
let name = bump.alloc_str(reader.get_name()?.to_str()?);
let params = read_list!(bump, reader, get_params, read_param);
let constraints = read_scalar_list!(bump, reader, get_constraints, model::TermId);
let r#type = model::TermId(reader.get_type());
let decl = bump.alloc(model::AliasDecl {
name,
params,
constraints,
r#type,
});
model::Operation::DeclareAlias { decl }
Expand Down
2 changes: 0 additions & 2 deletions hugr-model/src/v0/binary/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,13 @@ fn write_operation(mut builder: hugr_capnp::operation::Builder, operation: &mode
let mut builder = builder.init_alias_defn();
builder.set_name(decl.name);
write_list!(builder, init_params, write_param, decl.params);
let _ = builder.set_constraints(model::TermId::unwrap_slice(decl.constraints));
builder.set_type(decl.r#type.0);
builder.set_value(value.0);
}
model::Operation::DeclareAlias { decl } => {
let mut builder = builder.init_alias_decl();
builder.set_name(decl.name);
write_list!(builder, init_params, write_param, decl.params);
let _ = builder.set_constraints(model::TermId::unwrap_slice(decl.constraints));
builder.set_type(decl.r#type.0);
}

Expand Down
2 changes: 0 additions & 2 deletions hugr-model/src/v0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,6 @@ pub struct AliasDecl<'a> {
pub name: &'a str,
/// The static parameters of the alias.
pub params: &'a [Param<'a>],
/// The constraints on the static parameters.
pub constraints: &'a [TermId],
/// The type of the alias.
pub r#type: TermId,
}
Expand Down
2 changes: 1 addition & 1 deletion hugr-model/src/v0/text/hugr.pest
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ node_custom = { "(" ~ (term_apply | term_apply_full) ~ port_lists? ~

signature = { "(" ~ "signature" ~ term ~ ")" }
func_header = { symbol ~ param* ~ where_clause* ~ term ~ term ~ term }
alias_header = { symbol ~ param* ~ where_clause* ~ term }
alias_header = { symbol ~ param* ~ term }
ctr_header = { symbol ~ param* ~ where_clause* ~ term }
operation_header = { symbol ~ param* ~ where_clause* ~ term }

Expand Down
2 changes: 0 additions & 2 deletions hugr-model/src/v0/text/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,13 +576,11 @@ impl<'a> ParseContext<'a> {
let mut inner = pair.into_inner();
let name = self.parse_symbol(&mut inner)?;
let params = self.parse_params(&mut inner)?;
let constraints = self.parse_constraints(&mut inner)?;
let r#type = self.parse_term(inner.next().unwrap())?;

Ok(self.bump.alloc(AliasDecl {
name,
params,
constraints,
r#type,
}))
}
Expand Down
2 changes: 0 additions & 2 deletions hugr-model/src/v0/text/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ impl<'p, 'a: 'p> PrintContext<'p, 'a> {
});

this.print_params(decl.params)?;
this.print_constraints(decl.constraints)?;

this.print_term(decl.r#type)?;
this.print_term(*value)?;
Expand All @@ -308,7 +307,6 @@ impl<'p, 'a: 'p> PrintContext<'p, 'a> {
});

this.print_params(decl.params)?;
this.print_constraints(decl.constraints)?;

this.print_term(decl.r#type)?;
this.print_meta(node_data.meta)?;
Expand Down

0 comments on commit a05ae29

Please sign in to comment.