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

New fixity/iterator syntax #2332

Merged
merged 25 commits into from
Sep 14, 2023
Merged

New fixity/iterator syntax #2332

merged 25 commits into from
Sep 14, 2023

Conversation

janmasrovira
Copy link
Collaborator

@janmasrovira janmasrovira commented Sep 1, 2023

This pr implements the syntax changes described in #2330. It drops support for the old yaml-based syntax.
Some valid examples:

syntax iterator for {init := 1; range := 1};

syntax fixity cons := binary {assoc := right};
syntax fixity cmp := binary;
syntax fixity cmp := binary {}; -- debatable whether we want to accept empty {} or not. I think we should

Future work

This pr creates an asymmetry between iterators and operators definitions. Iterators definition do not require a constructor. We could add it to make it homogeneous, but it looks a bit redundant:

syntax iterator for := mkIterator {init := 1; range := 1};

We could consider merging iterator and fixity declarations with this alternative syntax.

syntax XXX for := iterator {init := 1; range := 1};

syntax XXX cons := binary {assoc := right};

where XXX is a common keyword. Suggestion by @lukaszcz XXX = declare

@janmasrovira janmasrovira added this to the 0.4.4 milestone Sep 1, 2023
@janmasrovira janmasrovira self-assigned this Sep 1, 2023
@janmasrovira janmasrovira force-pushed the new-fixity-syntax branch 2 times, most recently from 0fd5b38 to 7ddaef2 Compare September 5, 2023 14:09
@janmasrovira janmasrovira marked this pull request as ready for review September 5, 2023 14:19
@lukaszcz
Copy link
Collaborator

lukaszcz commented Sep 6, 2023

The syntactical asymmetry between iterator and fixity is justified because fixity declares a new idenfitier and assigns fixity to it, while iterator declares an already existing identifier to be an iterator.

@jonaprieto jonaprieto modified the milestones: 0.4.4, 0.5 Sep 7, 2023
@lukaszcz lukaszcz self-requested a review September 7, 2023 14:17
src/Juvix/Compiler/Concrete/Keywords.hs Show resolved Hide resolved
src/Juvix/Compiler/Concrete/Keywords.hs Show resolved Hide resolved
src/Juvix/Compiler/Concrete/Language.hs Outdated Show resolved Hide resolved
src/Juvix/Compiler/Concrete/Language.hs Show resolved Hide resolved
src/Juvix/Compiler/Concrete/Language.hs Outdated Show resolved Hide resolved
tests/positive/Termination/Data/Nat.juvix Show resolved Hide resolved
@lukaszcz
Copy link
Collaborator

lukaszcz commented Sep 7, 2023

This PR contains large deltas with formatting changes putting newlines everywhere. Is this a result of a different version/configuration of ormolu or was this intentional?

Personally, I think inserting these newlines makes things less readable. But even if we decide to change the coding style to insert newlines in these places, we should do it in a separate PR.

@jonaprieto jonaprieto marked this pull request as draft September 12, 2023 10:01
@janmasrovira janmasrovira marked this pull request as ready for review September 13, 2023 08:00
@janmasrovira janmasrovira marked this pull request as draft September 13, 2023 16:57
This reverts commit 175cc60.
@janmasrovira janmasrovira marked this pull request as ready for review September 14, 2023 07:45
@jonaprieto jonaprieto merged commit 8daca2b into main Sep 14, 2023
@jonaprieto jonaprieto deleted the new-fixity-syntax branch September 14, 2023 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants