View Related Documents

Abstract

Pattern matching is a great convenience in programming. However, pattern matching has its problems: it conflicts with data abstraction; it is complex (at least in Haskell, which has pattern guards, irrefutable patterns, n+k patterns, as patterns, etc.); it is a source of runtime errors; and lastly, one cannot abstract over patterns as they are not a first class language construct. This paper proposes a simplification of pattern matching that makes patterns first class. The key idea is to treat patterns as functions of type “a→Maybe b”|i.e., “a→(Nothing|Just b)”; thus, patterns and pattern combinators can be written as functions in the language.

Fulltext Preview

Image of the first page of the fulltext document