Skip to content
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

Merged
merged 6 commits into from
Jan 4, 2020

Conversation

Anabra
Copy link
Member

@Anabra Anabra commented Dec 16, 2019

In this PR, we address some of the problems that arose in #53 regarding the Old -> New AST conversion.

See #32.

It no longer extracts variables into new variables.
Now it removes resulting dead bindings after substitution.
@Anabra Anabra added the review Ready for review label Dec 16, 2019
@Anabra Anabra requested a review from andorp December 16, 2019 20:46
@Anabra Anabra self-assigned this Dec 16, 2019
@@ -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
Copy link
Member

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.

Copy link
Member Author

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,
Copy link
Member

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?

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

@Anabra Anabra merged commit db49996 into 32-extended-syntax Jan 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Ready for review
Projects
Rework GRIN IR
  
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

3 participants