title: Scala generics - type mismatch error when passing high order function as parameter
body: <p>I'm trying to pass high order generic function to another generic function as parameter. However, I am quite unable to make it work. Following is sample code of what I am trying to achieve.</p>
  
  <pre><code>def foo[T](data: Seq[T]) = {
      //some codes 
  }
  
  def bar[U](id: Sring, fn: Seq[U] =&gt; Unit) = {
      criteria match {
        case x =&gt; data:Seq[String] = //some data; 
                  fn(data)
        case b =&gt; data:Seq[Int] = //some data; 
                  fn(data)
        case c =&gt; data:Seq[Char] = //some data; 
                  fn(data)
      }
  }
  
  bar("123", foo)
  </code></pre>
  
  <blockquote>
    <p>If I run the code, I will get error - Type mismatch - expected Seq[U] found - Seq[String]</p>
  </blockquote>