title: How to compose Function<T, R> and Consumer<R> in Java 8?
body: <p>Why can't we compose Function and Consumer just like we compose functions?</p>
  
  <pre><code>Function&lt;Integer, String&gt; a = Object::toString;
  Consumer&lt;String&gt; b = x -&gt; System.out.println(x);
  Consumer&lt;Integer&gt; composed = a.andThen(b);
  </code></pre>
  
  <p>This seems like an obvious improvisation to the existing Function interface. Is there any reason why this capability was avoided in Java 8?</p>
  
  <p>Also, is it a common practice to use an extended implementation of Function as follows?</p>
  
  <pre><code>interface FunctionImproved&lt;T, R&gt; extends Function&lt;T, R&gt; {
      default Consumer&lt;T&gt; andThen(Consumer&lt;R&gt; consumer) {
          return x -&gt; consumer.accept(apply(x));
      }
  }
  </code></pre>