Skip to content

Commit

Permalink
Update extension json
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Aug 27, 2024
1 parent 43c728f commit f846a5c
Show file tree
Hide file tree
Showing 3 changed files with 617 additions and 3 deletions.
4 changes: 1 addition & 3 deletions hugr-core/src/std_extensions/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use crate::extension::simple_op::{MakeOpDef, MakeRegisteredOp};
use crate::extension::{ExtensionBuildError, OpDef, SignatureFunc, PRELUDE};
use crate::ops::constant::ValueName;
use crate::ops::{OpName, Value};
use crate::std_extensions::arithmetic::int_types;
use crate::types::{TypeName, TypeRowRV};
use crate::{
extension::{
Expand Down Expand Up @@ -234,8 +233,7 @@ lazy_static! {
/// Extension for list operations.
pub static ref EXTENSION: Extension = {
println!("creating collections extension");
let mut extension = Extension::new(EXTENSION_ID, VERSION)
.with_reqs(int_types::EXTENSION_ID);
let mut extension = Extension::new(EXTENSION_ID, VERSION);

// The list type must be defined before the operations are added.
extension.add_type(
Expand Down
308 changes: 308 additions & 0 deletions hugr-py/src/hugr/std/_json_defs/collections.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,205 @@
},
"values": {},
"operations": {
"concat": {
"extension": "collections",
"name": "concat",
"description": "Concatenate two lists",
"signature": {
"params": [
{
"tp": "Type",
"b": "A"
}
],
"body": {
"input": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
},
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
}
],
"output": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
}
],
"extension_reqs": []
}
},
"binary": false
},
"count": {
"extension": "collections",
"name": "count",
"description": "Count the number of times an element appears in a list",
"signature": {
"params": [
{
"tp": "Type",
"b": "A"
}
],
"body": {
"input": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
},
{
"t": "V",
"i": 0,
"b": "A"
}
],
"output": [
{
"t": "I"
}
],
"extension_reqs": []
}
},
"binary": false
},
"length": {
"extension": "collections",
"name": "length",
"description": "Get the length of a list",
"signature": {
"params": [
{
"tp": "Type",
"b": "A"
}
],
"body": {
"input": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
}
],
"output": [
{
"t": "I"
}
],
"extension_reqs": []
}
},
"binary": false
},
"lookup": {
"extension": "collections",
"name": "lookup",
"description": "Lookup an element in a list by index",
"signature": {
"params": [
{
"tp": "Type",
"b": "A"
}
],
"body": {
"input": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
},
{
"t": "I"
}
],
"output": [
{
"t": "V",
"i": 0,
"b": "A"
}
],
"extension_reqs": []
}
},
"binary": false
},
"pop": {
"extension": "collections",
"name": "pop",
Expand Down Expand Up @@ -138,6 +337,115 @@
}
},
"binary": false
},
"repeat": {
"extension": "collections",
"name": "repeat",
"description": "Repeat a list a number of times",
"signature": {
"params": [
{
"tp": "Type",
"b": "A"
}
],
"body": {
"input": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
},
{
"t": "I"
}
],
"output": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
}
],
"extension_reqs": []
}
},
"binary": false
},
"reverse": {
"extension": "collections",
"name": "reverse",
"description": "Reverse the elements in a list",
"signature": {
"params": [
{
"tp": "Type",
"b": "A"
}
],
"body": {
"input": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
}
],
"output": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
}
],
"extension_reqs": []
}
},
"binary": false
}
}
}
Loading

0 comments on commit f846a5c

Please sign in to comment.