title: Problem with Either and errors types incompatibility
body: <p>I have a problem with Either errors types incompatibility.</p>
  <p>A method to create Account entity:</p>
  <pre><code>static Either&lt;AccountError,Account&gt; create(
  String userNameCandidate,
  UserNameUniquenessValidator userNameUniquenessValidator,
  String passwordCandidate,
  PasswordEncoder passwordEncoder) {
  
     return UserName
              .create(userNameCandidate,userNameUniquenessValidator)
              .flatMap(correctUserName -&gt; Password
                      .create(passwordCandidate,passwordEncoder)
                      .map(correctPassword -&gt; new Account(correctUserName,correctPassword)));
  }
  </code></pre>
  <p>UserName and Password value objects:</p>
  <pre><code>@Embeddable
  final class UserName implements Serializable {
  
  public static final Integer MIN_USER_NAME_LENGTH = 3;
  
  public static final Integer MAX_USER_NAME_LENGTH = 15;
  
  @Column
  private final String userName;
  
  UserName(String userNam) {
      this.userName = userNam;
  }
  
  //For JPA only.Don't use!
  public UserName() {
  
      this.userName = &quot;default&quot;;
  }
  
  static Either&lt;WrongUserNameFormatError,UserName&gt; create(
          String userNameCandidate,
          UserNameUniquenessValidator userNameUniquenessValidator) {
  
      if (userNameCandidate.isEmpty()) {
  
          return Either.left(new WrongUserNameFormatError(&quot;Empty user name.&quot;));
      }
  
      var isUserNameCandidateLengthWrong =
              userNameCandidate.length() &lt; MIN_USER_NAME_LENGTH &amp;&amp;
              userNameCandidate.length() &gt; MAX_USER_NAME_LENGTH;
  
      if (isUserNameCandidateLengthWrong) {
  
          return Either.left(new WrongUserNameFormatError(
                      &quot;Wrong user name length: &quot; + userNameCandidate.length() +
                              &quot;.Min: &quot; + MIN_USER_NAME_LENGTH +
                              &quot;.Max: &quot; + MAX_USER_NAME_LENGTH));
      }
  
      if (!userNameUniquenessValidator.isUnique(userNameCandidate)) {
  
          return Either.left(new WrongUserNameFormatError(&quot;Not unique user name: &quot; + 
  userNameCandidate));
      }
  
      return Either.right(new UserName(userNameCandidate));
  }
  
  public String getUserName() {
      return userName;
    }
  }
  
  @Embeddable
  final class Password implements Serializable {
  
  public static final Integer MIN_PASSWORD_LENGTH = 5;
  
  @Column
  private final String password;
  
  private Password(String password) {
      this.password = password;
  }
  
  //For JPA only.Don't use!
  public Password() {
  
      this.password = &quot;default&quot;;
  }
  
  static Either&lt;WrongPasswordFormatError,Password&gt; create(String passwordCandidate, PasswordEncoder passwordEncoder) {
  
      if (passwordCandidate.length() &gt;= MIN_PASSWORD_LENGTH) {
  
          var encodedPassword= passwordEncoder.encode(passwordCandidate);
  
          return Either.right(new Password(encodedPassword));
      }
      else {
  
          return Either.left(new WrongPasswordFormatError(
                      &quot;Wrong password length: &quot; + passwordCandidate.length() +
                              &quot;. Min: &quot; + MIN_PASSWORD_LENGTH));
      }
  }
  
  public String getPassword() {
      return password;
  }
  </code></pre>
  <p>}</p>
  <p>I get error: Required Either&lt;AccountError,Account&gt;, provided Either&lt;WrongUserNameFormat, Object&gt;, incompatible constraint: AccountError and WrongUserNameFormatError even though all errors extends AccountError.</p>