Replies: 8 comments 17 replies
-
I'm thinking of the example compiler in the mlir docs, which adds a tensor type which is parameterised over some dimensions, i.e. In the extensibility example in our docs, we have arrays of a fixed length which are written as When a plugin developer specifies types, they should be able to specify some type parameters, then when that type is put in the signature of a function, that signature specifies what the type parameters are. Be they from typeargs bound by the signature or constants. Hence, when I declare the opaque type "Array", I write
I can then write a function signature like so:
|
Beta Was this translation helpful? Give feedback.
-
Yes, this is what I meant ( So looking here: https://github.com/CQCL-DEV/hugr/blob/43ae6bac774c39b3f513259530b9761261c1fc15/src/types/custom.rs#L13-L16 I think this "TypeRow" is wrong for a definition - that’d mean the params to a CustomType was a row like [Qubit, Int], and not allow saying that the type def wants “a type” as a parameter - e.g. if you try defining List as a CustomType. (I think this is what Conor would call a “kinding error”.) So I think the fix parallels what #186 does with CustomOp and OpDef - we should split CustomType into two: maybe TypeDef (like OpDef, belongs to a resource, may be of a higher kind like So the Resource contains TypeDefs, which have a List not a TypeRow; the SimpleType hierarchy contains the instantiation, which has a reference (by name, I think, rather than Arc**) to the CustomTypeDef, and a List (a bit like a List but that also allows passing in types). ** because we call The question is then about the exact form / variants of TypeParam / TypeArgValue, see #186 |
Beta Was this translation helpful? Give feedback.
-
That is to say, I don't see why the same system shouldn't be used for both OpDef and TypeDef, but the TypeParam/TypeArgValue may not be it. Parameters/arguments could be two separate lists
We could combine these à la TypeParam/TypeArgValue, as having to write types before values is slightly restrictive, but separating them does fit quite neatly with the Rust types/structs/etc. that we have already. |
Beta Was this translation helpful? Give feedback.
-
Oh, crap. I think we do not want types indexed by a float? Then it becomes hard to check types for equality. I mean, we can just not define/derive |
Beta Was this translation helpful? Give feedback.
-
Pushed something like the above to #186, but will be good to refactor in the future |
Beta Was this translation helpful? Give feedback.
-
However, further discussion, I think we conclude:
|
Beta Was this translation helpful? Give feedback.
-
I've pretty much done that, but will make an issue to refactor further so we can have proper containers. For example, List<Tuple<Type, Int>> is a good parameterization for "an arbitrary rank matrix where each row, column, etc., has a header" (and there's a type for row headers, a different type for column headers, and so on) |
Beta Was this translation helpful? Give feedback.
-
Time to close discussion? |
Beta Was this translation helpful? Give feedback.
-
Discussion started here:
#186 (comment)
It is unclear what data specifies a CustomType
Beta Was this translation helpful? Give feedback.
All reactions