Matt Roberts is a Lecturer in the Department of Computing at Macquarie University in Sydney, Australia. He has extensive industry experience as a developer and software engineer. Matt’s research interests are in functional programming, type systems and software language engineering.
YOW! Lambda Jam 2013 Brisbane
Beyond Conditionals: Active Patterns in F#
Pattern matching is widely used in functional languages to support ‘programming by cases.’ Common patterns such as tuples and discriminated unions are usually built into the language, but with F# active patterns you can extend pattern matching with your own classification and destructuring logic, capturing chains of if-else-else logic in a readable, reusable abstraction.
In this talk, we’ll take a tour of the various active pattern techniques available in F#, including cases, conditions and parameterised patterns. We’ll explore how to define each kind of active pattern, how to use it in a match expression and where you might apply it in your code.