title: Repeatable pattern matching
body: <p>Consider the following simple example.</p>
  
  <pre><code>type PaymentInstrument =
      | Check of string
      | CreditCard of string * DateTime
  
  let printInstrumentName instrument = 
      match instrument with 
      | Check number-&gt; printfn "check"
      | CreditCard (number, expirationDate) -&gt; printfn "card"
  
  let printRequisites instrument =
      match instrument with 
      | Check number -&gt; printfn "check %s" number
      | CreditCard (number, expirationDate) -&gt; printfn "card %s %A" number expirationDate
  </code></pre>
  
  <p>As you can see the same pattern matching logic is repeated in two functions. If I would use OOP I would create interface <code>IPaymentInstrument</code>, define two operations:</p>
  
  <p><code>PrintInstrumentName</code> and <code>PrintRequisites</code></p>
  
  <p>and then implement classes - one per payment instrument. To instantiate instrument depending on some external conditions I would use (for example) the factory pattern (<code>PaymentInstrumentFactory</code>).</p>
  
  <p>If I would need to add a new payment instrument, I just need to add a new class which implements <code>IPaymentInstrument</code> interface and update factory instantiating logic. Other code that uses these classes remains as is.</p>
  
  <p>But if I use the functional approach I should update <em>each</em> function where pattern matching on this type exists. </p>
  
  <p>If there will be a lot of functions using <code>PaymentInstrument</code> type that will be a problem.</p>
  
  <p>How to eliminate this problem using functional approach?</p>