-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Extended syntax: syntax conversion fix #59
Conversation
It no longer extracts variables into new variables.
Now it removes resulting dead bindings after substitution.
@@ -69,5 +69,8 @@ copyPropagation e = hylo folder builder (mempty, e) where | |||
| val == lpat | |||
, isConstant val | |||
-> rightExp | |||
-- left unit law ; cleanup x <- pure y copies |
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.
Write more detailed comment about the reason the dead variable removal is needed. It will not be obvious in the future.
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.
Done
@@ -125,16 +125,40 @@ instance Convertible Exp New.Exp where | |||
convert exp = fst $ evalNameM exp $ flip anaM exp $ \case | |||
(Program exts defs) -> pure $ New.ProgramF (map convert exts) defs | |||
(Def name args body) -> pure $ New.DefF (convert name) (map convert args) body | |||
{- NOTE: we assume Binding Pattern Simplification has been run | |||
|
|||
{- NOTE: We assume Binding Pattern Simplification has been run, |
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.
Is there an easy way to check that assumption?
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.
Looking at the code snippet it is not clear, why it does the trick. Please could you explain it?
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.
This function is only called after nameEverything
. The other cases are deliberately left out to get a runtime error, so we know that the conversion failed.
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 added a more detailed error message to the transformation.
In this PR, we address some of the problems that arose in #53 regarding the
Old -> New
AST conversion.See #32.