title: Scala automatic type inference in polymorphic functions
body: <p>How can I make this work?  My task at hand is a little bit more complicated but it boils down to this:</p>
  
  <pre><code>object Z {
    class B extends Function1[Int, Int] {
      def apply(i: Int): Int = i
    }
  
    def compose[T &lt;: Function1[X, X], X](fcts: List[T]): Function1[X, X] = {
      fcts.reduce(_ andThen _)
    }
  
    def test() = {
      val fcts = List.empty[B]
  
      // Unspecified type parameter X
      val composed: Function1[Int, Int] = compose[B](fcts)
    }
  }
  </code></pre>
  
  <p>I don't know how to define the "compose" function to be able to receive some concrete class B and automatically infer the dependent types X</p>