title: Record type pattern matching in Ocaml
body: <p>I'm trying to use pattern matching to write a calculator application.</p>
  
  <p>Two major types defined as below:</p>
  
  <pre><code>type key = Plus | Minus | Multi | Div | Equals | Digit of int;;
  
  type state = {
      lcd: int; (* last computation done *)
      lka: key; (* last key actived *)
      loa: key; (* last operation actived *)
      vpr: int (* value print on the screen *)
  };;
  
  let print_state s =
      match s with
       state (a,_,_,d) -&gt; print_int a; //Here has the compile error
                  print_newline();
                  print_int d;
                      print_newline();;
  </code></pre>
  
  <p>However, if I have a state like:</p>
  
  <pre><code>let initial_state = { lcd=0; lka=Equals; loa=Equals; vpr=0 } ;; 
  </code></pre>
  
  <p>Then when I invoke the function:</p>
  
  <pre><code>print_state initial_state;;
  </code></pre>
  
  <p>It will have the compile error. Anyone can tell what's the reason for unsuccessful compilation. Thanks in adv.</p>
  
  <pre><code>Error: Syntax error
  unexpected token "("
  </code></pre>