title: Is it possible to nest generics in a typescript type definition?
body: <p>I want to define a map function, that can generically transform any container. Whether that is an array, or a stream, or an observable, or any old monad etc.
  I think in order to model this, I need some form of nested generics. So that I can define <code>&lt;T&lt;U&gt;&gt;</code>.</p>
  
  <pre><code>let f : (
      fn: (a:number) =&gt; string,
      list:number[]     
  ) =&gt; string[]
  
  var toFixed = (a=0) =&gt; a.toFixed(2)
  var list = [1,2,3]
  
  f( toFixed , list ) //=&gt; string[] ✓
  
  // but what if I want to make the array's generic?
  let f2 : &lt;T,U&gt;(
      fn: (a:T) =&gt; U,
      list:T[]     
  ) =&gt; U[]
  
  // that's simple
  f2(toFixed, list) //=&gt; string[] ✓
  
  // but how do you support generic *containers*?
  // so that instead of an array, its an Observable, or
  // any Monad or Functor?
  
  let f3 : &lt;T,U, V&gt; (
      fn: (a:T) =&gt; U,
      container: V&lt;T&gt;
  ) =&gt; V&lt;U&gt; 
  
  interface Observable &lt;T&gt; {}
  interface Maybe &lt;T&gt; {}
  interface Future&lt;T&gt; {}
  
  let observable : Observable&lt;number&gt;
  let maybe : Maybe&lt;number&gt;
  let future : Future&lt;number&gt; 
  
  
  f3(toFixed, observable) // =&gt; any ✖
  // We want it to be: Observable&lt;string&gt;
  
  f3(toFixed, maybe) // =&gt; any ✖
  // We want it to be: Maybe&lt;string&gt;
  
  f3(toFixed, future) // =&gt; any ✖
  // We want it to be: Future&lt;string&gt;
  
  f3(toFixed, [1,2,3]) // =&gt; any ✖
  // We want it to be: string[]
  </code></pre>
  
  <p>If there is another way to model this behaviour, I'd like to hear any alternatives.</p>