You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A possible idea might be to use "matcher functions" for pattern matching. These would be simply functions that return either null, or any other value. When they return null, they are considered not to be a match. When they don't return null, they are considered to match their value.
A basic matcher function called match should be implemented. This function should take a tuple, for example $.age : $.age >= 18. If the condition in the second element is true, match $.age : $.age >= 18 should return $.age, otherwise it should return null.
An even better implementation for this could be a custom datatype only used for pattern matching. This datatype could encode a value + whether it's a matching value or not, and could be created using matchSuccess or matchFailure.
This combined with creating new matchers by wrapping existing matchers in data structures, etc should be quite powerful.
It would be also nice to reuse operators + and | in some way to create combined matchers. That should enable using P.alt, P.seq etc.. from parsimmon to match patterns in strings. related to #347
The basic idea is to have a syntax similar to this:
The text was updated successfully, but these errors were encountered: