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

feat: type-safe pattern matching #904

Merged
merged 7 commits into from
Feb 7, 2024
Merged

Conversation

thetayloredman
Copy link
Contributor

@thetayloredman thetayloredman commented Jan 17, 2024

This PR implements type-safety and inference for match statements.

Closes #802

  • "cases" syntax for matches
    • redundancy check
  • "when-chaining" syntax for matchers
    • redundancy check
    • fix autocomplete
    • Properly handle type validation errors
  • "unrestricted matching" (match())
  • "restricted matching" (match.only<T>())
    • Exhaustiveness checking
      • Properly handle constraints
  • Explicit finalization
  • Runtime impl with an ordered union of morphs
  • .or methods
    • Implicit finalization
    • .default
      • Properly infer parameter as remaining cases in a match.only
      • With a non-function value, .default(x) behaves as .default(_ => x)
    • .orThrow
  • Tests
  • Run benchmarks
  • Handle non-is-narrowed cases
    • Regex literals
    • predicates
  • Bugs:
    • Constraints are not distilled in cases notation

@ssalbdivad ssalbdivad marked this pull request as ready for review February 7, 2024 20:23
@ssalbdivad ssalbdivad merged commit 4ae4310 into arktypeio:beta Feb 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done (merged or closed)
Development

Successfully merging this pull request may close these issues.

None yet

2 participants