Active Patterns

Active Patterns are conceptually similar to discriminated unions. What really changes is how they are used, not the syntax.

By definition, it can be said that an active pattern is a set of called partitions used to compare the input data. Also, these partitions (labels) can be used in expression.

This is the syntax:

let (|identifer1|identifier2|...|) [ arguments ] = expression 
let (|identifier|_|) [ arguments ] = expression 

As we can see in the preceding code lines, there are two different implementations. They are as follows:

  • Complete Active Patterns: They are described in the first row and all the labels are explicitly denominated. They must be a maximum of seven and each one must have a result return.
  • Partial Active Patterns: It ...

Get Reactive Programming for .NET Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.