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(common): add pattern matchers #5824

Closed
wants to merge 8 commits into from
Closed

Conversation

kszucs
Copy link
Member

@kszucs kszucs commented Mar 25, 2023

Converted the previous validator system into a pattern matching system.

The previously used validator system had the following problems:

  • Used curried functions which was error prone to missing arguments and was hard to debug.
  • Used exceptions for control flow which raising exceptions from the innermost function call giving cryptic error messages.
  • While it was similarly composable it was hard to see whether the validator was fully constructed or not.
  • We wasn't able traverse the nested validators due to the curried functions.

In addition to those the new approach has the following advantages:

  • The pattern matching system is fully composable.
  • Not we support syntax sugar for combining patterns using & and |.
  • We can capture values at mutiple levels using either >> or @ syntax.
  • Support structural pattern matching for sequences, mappings and objects.
  • We will be able to cache the pattern matches more easily.

The following TODOs are left:

  • refactor the validators to provide a backward compatibility API but using the new patterns under the hood
  • switch to use the new patterns everywhere in ibis core

but going to handle them in #5899

@cpcloud cpcloud added refactor Issues or PRs related to refactoring the codebase datatypes Issues relating to ibis's datatypes (under `ibis.expr.datatypes`) labels Mar 27, 2023
@cpcloud cpcloud added this to the 6.0 milestone Mar 27, 2023
@kszucs kszucs changed the base branch from master to 6.x.x March 28, 2023 10:13
@kszucs kszucs force-pushed the 6.x.x branch 2 times, most recently from 7085054 to ec8e92f Compare March 29, 2023 11:09
@kszucs kszucs marked this pull request as ready for review April 3, 2023 12:03
@kszucs kszucs changed the title refactor(common): turn the validators into pattern matchers feat(common): add patter matchers Apr 11, 2023
@kszucs kszucs changed the title feat(common): add patter matchers feat(common): add pattern matchers Apr 11, 2023
@kszucs kszucs force-pushed the 6.x.x branch 2 times, most recently from 16c202b to b2ed079 Compare April 13, 2023 10:46
@kszucs
Copy link
Member Author

kszucs commented Apr 17, 2023

Closing in favor #5899

@kszucs kszucs closed this Apr 17, 2023
@kszucs kszucs deleted the patterns branch May 16, 2023 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datatypes Issues relating to ibis's datatypes (under `ibis.expr.datatypes`) refactor Issues or PRs related to refactoring the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants