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

Binder refactor #1598

Merged
merged 14 commits into from
Oct 28, 2022
Merged

Binder refactor #1598

merged 14 commits into from
Oct 28, 2022

Conversation

janmasrovira
Copy link
Collaborator

@janmasrovira janmasrovira commented Oct 25, 2022

Important changes:

  1. Remove BinderInfo and replace it with an explicit field of type Binder in the nodes where it makes sense. Currently Binder is only a name and a type. We may need to extend it or make it dynamically extensible in the future.
  2. Node' is now also parameterized by the type in its binders.
  3. Refactor destruct to make it easier to understand and less error prone (hopefully).
    Before we had the following fields in NodeDetails:
         -- | 'nodeChildren' are the children, in a fixed order, i.e., the immediate
         -- recursive subnodes
        _nodeChildren :: [Node],
         -- | 'nodeChildBindersNum' is the number of binders introduced for each
         -- child in the parent node. Same length and order as in `nodeChildren`.
         _nodeChildBindersNum :: [Int],
         -- | 'nodeChildBindersInfo' is information about binders for each child, if
         -- present. Same length and order as in `nodeChildren`.
         _nodeChildBindersInfo :: [[Info]],
    All the three list need to match their length.
    I have introduced a new data type NodeChild that has the same information as before but grouped nicely. All the previous fields are now merged in a single list:
        _nodeChildren :: [NodeChild]
    where
    data NodeChild = NodeChild {
    -- | immediate child of some node
    _childNode :: Node,
    -- | Binders introduced by the child
    _childBinders :: [Binder],
    -- | length of `_childBinders`
    _childBindersNum :: Int
    }

Other changes:

  1. Introduce types LambdaLhs and PiLhs, which are useful for unfolding and folding.
  2. The semicolon after the last item in a letrec is no longer optional for consistency.

@janmasrovira janmasrovira added refactor core Related to JuvixCore labels Oct 25, 2022
@janmasrovira janmasrovira self-assigned this Oct 25, 2022
@janmasrovira janmasrovira marked this pull request as ready for review October 26, 2022 23:16
lukaszcz
lukaszcz previously approved these changes Oct 28, 2022
src/Juvix/Compiler/Core/Language/Nodes.hs Show resolved Hide resolved
src/Juvix/Compiler/Core/Translation/FromSource.hs Outdated Show resolved Hide resolved
@lukaszcz lukaszcz merged commit 59e6712 into main Oct 28, 2022
@lukaszcz lukaszcz deleted the binder-refactor branch October 28, 2022 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to JuvixCore refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants