title: When to use PECS when designing a library?
body: <p>I am working on a library which makes heavy use of functional interfaces and currently struggle whether to apply <a href="https://stackoverflow.com/questions/2723397/what-is-pecs-producer-extends-consumer-super?rq=1">PECS</a> or not:</p>
  
  <pre><code>Predicate&lt;A&gt;
  Function&lt;A,B&gt;
  BiFunction&lt;A,B,C&gt;
  </code></pre>
  
  <p>vs.</p>
  
  <pre><code>Predicate&lt;? super A&gt;
  Function&lt;? super A, ? extends B&gt;
  BiFunction&lt;? super A,? super B,? extends C&gt;
  </code></pre>
  
  <p>It just seems so cluttered and even the error messages turn from:</p>
  
  <pre><code>Incompatible types: Function&lt;Item, Long&gt; is not convertible to Function&lt;Item, String&gt;
  </code></pre>
  
  <p>to something like </p>
  
  <pre><code>Incompatible types: 
  Function&lt;capture of ? super Item, capture of ? extends Long&gt; is not 
  convertible to Function&lt;capture of ? super Item, capture of ? extends String&gt;
  </code></pre>
  
  <p>which is so hard to read. I have read the <a href="https://stackoverflow.com/questions/50313830/why-many-java-stream-interface-methods-use-lower-bounded-wildcard-in-parameters">following question</a> but still struggle whether to apply it or not as it pollutes the library code and worsens the compiler error messages. Personally I would opt for PCES for the <code>Predicate&lt;A&gt;</code> variants.</p>
  
  <p>Is there some guideline whether to apply PECS or not? I know the pros and cons but I wonder how often people really store e.g. <code>Predicate</code> in fields as lamdas and method references are not affected by what PECS offers. I did not find any further advice on the web. <a href="https://github.com/roookeee/datus/blob/5bbb1a4e46852566f2acac0a44f12b5d459296df/src/main/java/com/github/roookeee/datus/immutable/ConstructorParameterBinding.java" rel="nofollow noreferrer">Here</a> is one of the classes affected by this.</p>