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: case hoisting #90

Merged
merged 5 commits into from
Apr 19, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ hoistAlts :: Name -> (Alt, Alt) -> NameM Alt
hoistAlts lpatName (Alt cpat1 altName1 alt1, Alt cpat2 altName2 alt2) = do
freshLPatName <- deriveNewName lpatName
let nameMap = Map.singleton lpatName freshLPatName
(freshAlt2, _) <- case cpat2 of
DefaultPat -> refreshNames nameMap alt2
_ -> refreshNames nameMap $ EBind (SReturn $ Var freshLPatName) (VarPat altName2) alt2
(freshAlt2, _) <- refreshNames nameMap $
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the problem here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the default alt also has a name. It has to be rebound when hoisting the default alt into some other alt. See the default pattern test case.

EBind (SReturn $ Var freshLPatName) (VarPat altName2) alt2
pure . Alt cpat1 altName1 $ EBind (SBlock alt1) (VarPat freshLPatName) freshAlt2

disjointMatch :: [(Set Tag, Alt)] -> [Alt] -> Maybe [(Alt, Alt)]
Expand Down