concept pattern matching in category functional programming

appears as: pattern matching
Functional Programming in C++

This is an excerpt from Manning's book Functional Programming in C++.

What is functional programming (FP)? This question is difficult to answer because no widely accepted definition exists. There’s a saying that if you ask two functional programmers what FP is, you’ll get (at least) three different answers. People tend to define FP through related concepts including pure functions, lazy evaluation, pattern matching, and such. And usually, they list the features of their favorite language.

The Mach7 library (https://github.com/solodon4/Mach7) was created by Yuriy Solodkyy, Gabriel Dos Reis, and Bjarne Stroustrup, and serves as an experiment that will eventually be used as the base for extending C++ to support pattern matching. Although the library started as an experiment, it’s considered stable enough for general use. It’s generally more efficient than the visitor pattern (not to be confused with std::visit for variants). The main downside of Mach7 is its syntax.

Functional Programming in C#: How to write better C# code

This is an excerpt from Manning's book Functional Programming in C#: How to write better C# code.

On one hand, it was disappointing that only the last item could be delivered. C# 7 also includes a limited implementation of pattern matching, but it’s a far cry from the kind of pattern matching available in functional languages, and it’s generally inadequate for the way we’d like to use pattern matching when programming functionally (see section 10.2.4).

On the other hand, these features are still on the table for future versions, and work has been done on the respective proposals. This means we’re likely to see record types and a more complete implementation of pattern matching in future versions of C#. So C# is poised to continue in its evolution as a multi-paradigm language with an increasingly strong functional component.

C#’s incipient support for pattern matching

Pattern matching is a language feature that allows you to execute different code depending on the “shape” of some data—most importantly, its type. It’s a staple of functional languages. You can think of the classic switch statement as a very limited form of pattern matching, because you can only match on the exact value of an expression. What if you want to match on the type of an expression?