Skip to content

Conversation

@qodot
Copy link
Owner

@qodot qodot commented Dec 21, 2025

Summary

  • Add tuple pattern matching for compound pattern scenarios (e.g., (Dog, Car), ("success", "instagram"))
  • Support multi-argument lambdas that receive unpacked tuple elements
  • Refactor codebase: extract ExhaustiveError and helper functions to separate modules

Changes

New Features

  • Tuple pattern matching: Match against tuple patterns combining types and literals
    • Value tuples: ("success", "instagram")
    • Type tuples: (Dog, Car)
    • Mixed tuples: ("instagram", Dog)
  • Multi-arg lambda support: lambda d, c: f"{d.speak()} {c.drive()}"

Refactoring

  • Extract ExhaustiveError to error.py
  • Extract helper functions to helper.py:
    • is_not_callable(), is_class(), get_callable_param_count()
    • is_tuple_pattern(), match_element(), match_tuple()
    • unwrap() with tuple unpacking support
  • Add check_match() function for unified pattern matching logic

Tests

14 new tests added in test_match__tuple.py covering all tuple pattern scenarios.

@qodot qodot marked this pull request as ready for review December 21, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant