title: How to work with generics of nested types in scala
body: <p>I'm building a small API around some spark code and I am finding myself creating traits like the following:</p>
  
  <pre><code>trait DataSource[T, F] {
      def run(config: DataSourceConfig[T,F]): DataSourceResource[F]
  }
  </code></pre>
  
  <p>Take type T to represent RDD[F]. Do you see the problem here? It's getting obnoxious here having to force users to define both types like this:</p>
  
  <pre><code>class MySource extends DataSource[RDD[String], String] {
  
  
  }
  </code></pre>
  
  <p>I understand scala has some black magic when it comes to generics that may allow me to specify that F is really a type nested within T but I can't seem to figure out how it would be done. </p>
  
  <p>Thing is- T could also be a DStream[String]. RDD and DStream do not inherit from the same trait or base class.</p>
  
  <p>Any ideas? It would really clean up my API if I could just specify that F is nested within T and still be able to use F everywhere.</p>