title: have method implement from interface yet override generic type
body: <p>I have an interface as below:</p>
  
  <pre><code>public interface Functor&lt;T&gt; {
      public &lt;R&gt; Functor&lt;R&gt; chain(Function&lt;T, Functor&lt;R&gt;&gt; f);
  }
  </code></pre>
  
  <p>and I want to implement such that:</p>
  
  <pre><code>public abstract class Either&lt;T&gt; implements Functor&lt;T&gt; {
      private static class Right&lt;T&gt; extends Either&lt;T&gt; {
          private T val;
  
          private Right(final T val) {
              this.val = val;
          }
  
          public &lt;R&gt; Either&lt;R&gt; chain (final Function&lt;T, Either&lt;R&gt;&gt; f) {
              return f.apply(this.val);
          }
      }
  }
  </code></pre>
  
  <p>The reason being that I want to be able to "chain" over any <code>Functor&lt;T&gt;</code> yet I want those functors to require that the same type as it is returned by chain.</p>
  
  <p>The only way I was able to get this to work was:</p>
  
  <pre><code>public interface Functor&lt;T&gt; {
      public &lt;R&gt; Functor&lt;R&gt; chain(Function&lt;T, ? extends Functor&lt;R&gt;&gt; f);
  }
  
  public abstract class Either&lt;T&gt; implements Functor&lt;T&gt; {
      public static class Right&lt;T&gt; extends Either&lt;T&gt; {
          private T val;
  
          private Right(final T val) {
              this.val = val;
          }
  
          public &lt;R&gt; Either&lt;R&gt; chain(final Function&lt;T, ? extends Functor&lt;R&gt;&gt; f) {
              return (Either&lt;R&gt;)f.apply(this.val);
          }
      }
  }
  </code></pre>
  
  <p>However this doesn't express exactly what I want... the type conversion to <code>(Either&lt;R&gt;)</code> isn't the best way to solve this for sure.</p>
  
  <p>Any attempt as putting <code>? extends Either&lt;R&gt;</code> or just <code>Either&lt;R&gt;</code> fails with "Right is not abstract and does not override abstract method &lt;R>chain..."</p>
  
  <p>Anyone have any idea of what I can do to solve this?
  IS there a way to do this?</p>