title: Chained references in python type annotations
body: <p>Say I have a function that takes a value and a arbitrary number of functions, let's call the function for chain_call.</p>
  
  <p>Without types a simple naive implementation would be: </p>
  
  <pre><code>def chain_call(input_value, *args):
      for function in args:
          input_value = function(input_value)
      return input_value
  </code></pre>
  
  <p>As you imagine, input_value could be anything really but it's always the same as the first and only required argument of the first <code>Callable</code> in <code>*args: List[Callable]</code>. </p>
  
  <p>From here and forward the <code>Callable</code>´s  first and only required argument is the same type as the previous items return-type.</p>
  
  <p>So far I've managed to define a quite generic type but it's too loose. </p>
  
  <pre><code>def chain_call(input_value: Any, *args: List[Callable[Any], Any]) -&gt; Any: ...
  </code></pre>
  
  <p>What I'd really like is something like</p>
  
  <pre><code>T = TypeVar('T')
  
  def chain_call(input_value: T, *args: List[Callable[T, ...], tr]) -&gt; tr: ...
  </code></pre>
  
  <p>Where <code>T</code> for <code>Callable n+1</code> is <code>tr</code> of <code>Callable n</code> and the final return-type is tr of <code>Callable n_max</code>. I'm not sure how to express this with the type system and would love any guidance.</p>