Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Matching polymorphic variant tags #7

Closed
jacobp100 opened this issue Jul 2, 2020 · 3 comments · Fixed by #11
Closed

Matching polymorphic variant tags #7

jacobp100 opened this issue Jul 2, 2020 · 3 comments · Fixed by #11

Comments

@jacobp100
Copy link

The syntax for matching a polymorphic variant type uses a double hashtag

type nums = [ | #one | #two | #three];

type alphas = [ | #a | #b | #c];

type alphanums = [ nums | alphas ];

let a: alphanums = #a;

switch a {
| ##alphas => Js.log("alphas")
| ##nums => Js.log("nums")
};

What if we used the spread operator? Either before or after the hashtag

switch a {
| #...alphas => Js.log("alphas")
| #...nums => Js.log("nums")
};
@IwanKaramazow
Copy link
Contributor

@jacobp100 this is a very good idea. I'll implement this!

@jfrolich
Copy link

jfrolich commented Jul 3, 2020

Yes more intuitive indeed!

chenglou added a commit to chenglou/syntax that referenced this issue Jul 3, 2020
chenglou added a commit to chenglou/syntax that referenced this issue Jul 3, 2020
@IwanKaramazow
Copy link
Contributor

@jacobp100 Thanks for the wonderful idea. This has been implemented.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants