samskivert: Extensible Pattern Matching Via a Lightweight Language Extension – Syme, et al.

06 July 2010

Describes the design of the pattern matching capabilities in F#, which they dub active patterns. The ability to create patterns after-the-fact for classes you may not even control seems quite useful. Even without the ability to “extract” internal representation from an instance (a much misunderstood feature of Scala’s pattern matching), one can still get a lot of mileage out of clean syntax for matching and variable binding. It’s a whole lot better than a pile of if statements and local variable declarations. As a bonus, with total patterns, the compiler can check that you covered all the cases.

Source: PDF ACM

©1999–2015 Michael Bayne