title: Swift: Passing in functions that throw exceptions
body: <p>I have the following toy example</p>
  
  <pre><code>func identity&lt;T&gt;(a : T) -&gt; T{
    return a
  }
  
  func applyIdentity&lt;T&gt;(f : T-&gt;T, t:T) -&gt; T{
    return f(t)
  }
  
  applyIdentity(identity, t:1)
  </code></pre>
  
  <p>And this works without a hitch. However, once I try to throw an exception in identity like so:</p>
  
  <pre><code>enum MyError: ErrorType{
    case MyErrorFoo
  };
  
  func identity&lt;T&gt;(a : T) throws -&gt; T{
    if (true) {
      return a
    } else {
      throw MyError.MyErrorFoo
    }
  }
  ...
  </code></pre>
  
  <p>The type checker complains on the <code>applyIdentity(identity, t:1)</code> call with message:</p>
  
  <pre><code>Argument for generic parameter 'T' could not be inferred
  </code></pre>
  
  <p>Any idea why this may be happening?</p>