title: Match Value with Function based on Type
body: <p>Suppose I have a list of functions as so:</p>
  
  <pre><code>val funcList = List(func1: A =&gt; T, func2: B =&gt; T, func2: C =&gt; T)
  </code></pre>
  
  <p>(where <code>func1</code>, et al. are defined elsewhere)</p>
  
  <p>I want to write a method that will take a value and match it to the right function based on exact type (match <code>a: A</code> with <code>func1: A =&gt; T</code>) or throw an exception if there is no matching function. </p>
  
  <p>Is there a simple way to do this? </p>
  
  <p>This is similar to what a <code>PartialFunction</code> does, but I am not able to change the list of functions in <code>funcList</code> to PartialFunctions. I am thinking I have to do some kind of implicit conversion of the functions to a special class that knows the types it can handle and is able to pattern match against it (basically promoting those functions to a specialized <code>PartialFunction</code>). However, I can't figure out how to identify the "domain" of each function. </p>
  
  <p>Thank you.</p>