pcase

Homepage: https://www.gnu.org/software/emacs

Author: Stefan Monnier

Summary

ML-style pattern-matching macro for Elisp

Commentary

ML-style pattern matching.
The entry points are autoloaded.

Todo:

- Allow to provide new `pcase--split-' thingy.
- provide something like (setq VAR) so a var can be set rather than
  let-bound.
- provide a way to continue matching to subsequent cases
  (e.g. Like Racket's (=> ID).
- try and be more clever to reduce the size of the decision tree, and
  to reduce the number of leaves that need to be turned into functions:
  - first, do the tests shared by all remaining branches (it will have
    to be performed anyway, so better do it first so it's shared).
  - then choose the test that discriminates more (?).
- provide Agda's `with' (along with its `...' companion).
- implement (not PAT).  This might require a significant redesign.
- ideally we'd want (pcase s ((re RE1) E1) ((re RE2) E2)) to be able to
  generate a lex-style DFA to decide whether to run E1 or E2.

While the first version was written before I knew about Racket's `match'
construct, the second version was significantly influenced by it,
so a good presentation of the underlying ideas can be found at:

  Extensible Pattern Matching in an Extensible Language
  Sam Tobin-Hochstadt, 2010
  https://arxiv.org/abs/1106.2578

Dependencies

Reverse dependencies