Open denismerigoux opened 2 years ago
Note for later, provided by Guillaume Boisseau: "Pour la compilation pattern-matching, les deux options sont: automate à rebroussement (par exemple http://pauillac.inria.fr/~maranget/papers/opat/ ) qui nécessite des gotos, ou arbre de décision (par exemple http://moscova.inria.fr/~maranget/papers/ml05e-maranget.pdf ) qui n'a pas besoin de goto mais risque l'exponentialité"
See https://caml.inria.fr/pub/docs/oreilly-book/html/book-ora016.html for reference about the features presented here.
Desired features
Wildcard pattern
Though the wildcard pattern is already present in the syntax, it is desugared by filling all patterns currently. #130 tracks progress on propagating the wildcard pattern down the compilation chain.
Combined patterns
We don't want to repeat the same arms for patterns that should have the same consequence. Like:
https://github.com/CatalaLang/catala/blob/7d9379e43c44c66b77d59d4823acda5f2c0d877c/examples/allocations_logement/code_construction_reglementaire.catala_fr#L513-L517
Deep matching
We would want to inspect enum and struct types in pattern matching patterns.
Challenges
All of these features would require a serious typechecking infrastructure in
compiler/dcalc/typechecker.ml
to deal with pattern matching exhaustiveness and produce good error messages. As this is a standard set of features, one might want to observe how reference implementation do it properly before diving in the implementation.