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

Value declaration with patterns on the left #9

Open
gisellemnr opened this issue Jun 10, 2021 · 0 comments
Open

Value declaration with patterns on the left #9

gisellemnr opened this issue Jun 10, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@gisellemnr
Copy link
Member

Currently we need to unpack all variables on the left of an SML declaration and create one Coq definition for each, duplicating some code. The SML code val x :: l = [1 ,2 ,3] becomes:

Definition x := match [1; 2; 3] with (x :: l) => x
                                   | _ => patternFailure
                end .
Definition l := match [1; 2; 3] with (x :: l) => l
                                   | _ => patternFailure
                end .

To avoid this duplication, we could use tuples:

Definition t := match [1; 2; 3] with (x :: l) => x
                                   | _ => patternFailure
                end .
Definition x := fst t.
Definition l := snd t.

Issues to solve when implementing this solution:

  • Name for t should be unique.
  • If the pattern has more than two variables, it is grouped (by Coq) ((1,2,3), 4). So fst returns another tuple. Depending on the index of the element, figure out how to organize fst and snd functions.
@gisellemnr gisellemnr added the enhancement New feature or request label Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant