title: How do I ignore exceptions in F#
body: <p>During normal program's execution an exception may occur.</p>
  
  <p>In case I'm aware of it and just want to ignore it — how do I achieve this in F#?</p>
  
  <p>Here is my code, which compiles with a warning:</p>
  
  <pre><code>let sha = new SHA1CryptoServiceProvider()
  let maxLength = 10000
  let fileSign file = 
      let fs = File.OpenRead(file)
      let mutable res = (0L, [|0uy|])
      try
          let flLen = fs.Length
          let len = int (min (int64 maxLength) flLen)
  
          // read 'len' bytes        
          let mutable pos = 0
          while (pos &lt; len) do
              let chunk = fs.Read(buf, pos, len - pos)
              pos &lt;- pos + chunk
  
          // get signature            
          let sign = sha.ComputeHash(buf, 0, len)
  
          // store new result
          res &lt;- (flLen, sign)        
      with
          | :? IOException as e -&gt; e |&gt; ignore
      finally 
          if (fs &lt;&gt; null) then
              fs.Dispose()
      res
  </code></pre>
  
  <p>The warning is:<br>
  <code>error FS0010: Unexpected keyword 'finally' in binding. Expected incomplete structured construct at or before this point or other token.</code></p>
  
  <p>The corresponding C# equivalent for what I want is:</p>
  
  <pre><code>FileStream fs = null;
  try
  {
      fs = File.OpenRead(file);
      // ... other stuff
  }
  catch
  {
      // I just do not specify anything
  }
  finally
  { 
      if (fs != null)
          fs.Dispose()
  }
  </code></pre>
  
  <p>If I just omit the <code>with</code> block in F#, the exception is not ignored.</p>