Functional Programming in PatternMatchOriented Programming Style Throughout the history of functional programming, recursion has emerged as a natural method for describing loops in programs. However, there does often exist a substantial cognitive distance between the recursive definition and the simplest explanation of an algorithm even for the basic list processing functions such as map, concat, or unique; when we explain these functions, we seldom use recursion explicitly as we do in functional programming. For example, map is often explained as follows: the map function takes a function and a list and returns a list of the results of applying the function to all the elements of the list.  :102,paper advocates a new programming paradigm called patternmatchoriented programming for filling this gap. An essential ingredient of our method is utilizing pattern matching for nonfree data types. Pattern matching for nonfree data types features nonlinear pattern matching with backtracking and extensibility of patternmatching algorithms. Several nonstandard pattern constructs, such as notpatterns, loop patterns, and sequential patterns, are derived from this patternmatching facility. Based on that result, this :102,paper introduces many programming techniques that replace explicit recursions with an intuitive pattern by confining recursions inside patterns. We classify these techniques as patternmatchoriented programming design patterns.  programming techniques :197,allow us to redefine not only the most basic functions for list processing such as map, concat, or unique more elegantly than the traditional functional programming style, but also more practical mathematical algorithms and software such as a SAT solver, computer algebra system, and database query language that we had not been able to implement concisely.

Elaborating dependent (co)pattern matching: No pattern left behind In a dependently typed language, we can guarantee correctness of our programmes by providing formal proofs. To check them, the typechecker elaborates these programs and proofs into a lowlevel core language. However, this core language is by nature hard to understand by mere humans, so how can we know we proved the right thing? This question occurs in particular for dependent copattern matching, a powerful language construct for writing programmes and proofs by dependent case analysis and mixed inductioncoinduction. A definition by copattern matching consists of a list of  clauses  that are elaborated to a  case tree , which can be further translated to primitive  eliminators . In previous work this second step has received a lot of attention, but the first step has been mostly ignored so far. We present an algorithm elaborating definitions by dependent copattern matching to a core language with inductive data types, coinductive record types, an identity type, and constants defined by welltyped case trees. To ensure correctness, we prove that elaboration preserves the firstmatch semantics of the user clauses. Based on this theoretical work, we reimplement the algorithm used by Agda to check lefthand sides of definitions by pattern matching. The new implementation is at the same time more general and less complex, and fixes a number of bugs and usability issues with the old version. Thus, we take another step towards the formally verified implementation of a practical dependently typed language.