title: unable to infer type in flatMap
body: <p><em>NetworkManager</em> class has <em>fetchData</em> generic function for fetching data from Internet.</p>
  <pre><code>class NetworkManager {
      
      func fetchData&lt;T: Decodable&gt;(url: URL) -&gt; AnyPublisher&lt;T, ErrorType&gt; {
          URLSession
              .shared
              .dataTaskPublisher(for: url)
              .tryMap { data, _ in
                  return try JSONDecoder().decode(T.self, from: data)
              }
              .mapError { error -&gt; ErrorType in
                  switch error {
                  case let urlError as URLError:
                      switch urlError.code {
                      case .notConnectedToInternet, .networkConnectionLost, .timedOut:
                          return .noInternetConnection
                      case .cannotDecodeRawData, .cannotDecodeContentData:
                          return .empty
                      default:
                          return .general
                      }
                  default:
                      return .general
                  }
              }
              .eraseToAnyPublisher()
      }
  
  }
  </code></pre>
  <p>In <em>HomeRepositoryImpl</em> class I am trying to get data from specific url with <em>AnyPublisher&lt;[CountryDayOneResponse], ErrorType&gt;</em> return value. I wanted to sort responed array, so I used <em>flatMap</em> on <em>NetworkManager</em> like this:</p>
  <pre><code>func getCountryStats(for countryName: String) -&gt; AnyPublisher&lt;[CountryDayOneResponse], ErrorType&gt; {
      let url = RestEndpoints.countryStats(countryName: countryName).endpoint()
  
      return NetworkManager().fetchData(url: url)
          .flatMap { result -&gt; AnyPublisher&lt;[CountryDayOneResponse], ErrorType&gt; in
              switch result {
              case .success(var response):
                  let filteredCountry = Array(response.sorted(by: {$0.date &gt; $1.date}))
                  response = filteredCountry
                  return response
              case .failure(let error):
                  return error
              }
          }
          .eraseToAnyPublisher()
  }
  </code></pre>
  <p>But I am getting <em>Unable to infer type of a closure parameter 'result' in the current context</em> error.</p>