-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Allow lists in py expressions #113
Conversation
6de5059
to
f0435e7
Compare
node, | ||
) from e | ||
|
||
python_val = eval_py_expr(node, self.ctx) | ||
if ty := python_value_to_guppy_type(python_val, node, self.ctx.globals): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why we're converting python_val
to a type. It's an arbitrary python value right? Just something inside a py(...)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'm looking up how python match
works...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we're checking that the Python expression inside py(...)
evaluates to something that is valid in Guppy and compute the corresponding Guppy type
@@ -67,6 +74,11 @@ def float_value(f: float) -> val.Value: | |||
return val.ExtensionVal(c=(ConstF64(value=f),)) | |||
|
|||
|
|||
def list_value(v: list[val.Value]) -> val.Value: | |||
"""Returns the Hugr representation of a list value.""" | |||
return val.ExtensionVal(c=(ListValue(value=v),)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the ,
do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(x,)
is a unary tuple. We need this because of some serialisation shenanigans...
Closes #114