Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[PoC] Allowing ad hoc aliasing of an or pattern of literals into a polyvariant#7801

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
zth wants to merge1 commit intomaster
base:master
Choose a base branch
Loading
fromimplement-alias-to-polyvariant

Conversation

@zth
Copy link
Member

@zthzth commentedAug 24, 2025
edited
Loading

Now that the runtime represenation of polyvariants is stable and well defined, we can allow aliasing or patterns of literals into a polyvariant if we want, since we can guarantee that if it matches it has been refined to the provided runtime representation.

Example:

typeabc= [#a |#b |#c]letuseABC= (x:abc)=>switchx {  |#a=>1  |#b=>2  |#c=>3  }letfromString=s=>switchs {  | ("a" |"b" |"c")as#...f=>useABC(f)// `f` will be a polyvariant of the literals matched on in the pattern. So `[#a | #b | #c]`.  |_=>0  }

Notes

For the implementation, we might need to check extra that the literals are valid as polyvariant constructors.

@pkg-pr-new
Copy link

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7801

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7801

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7801

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7801

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7801

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7801

commit:487cea6

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@zth

[8]ページ先頭

©2009-2025 Movatter.jp