title: Why is this code ambiguous?
body: <p>I've written this extension to <code>SequenceType</code> to mimic <a href="https://docs.python.org/2/library/collections.html#collections.Counter" rel="nofollow">Python's <code>collections.Counter</code></a>.</p>
  
  <pre><code>let input = [
      "a", "a", "a", "a", "a",
      "b", "b", "b", "b",
      "c", "c", "c",
      "d", "d",
      "e"
  ]
  
  
  let counts = input.countRepetitions()
  
  print(counts) //expected result: ["a": 5 , "b" : 4, "c" : 3, "d" : 2, "e" : 1]
  </code></pre>
  
  <p>Here's the code:</p>
  
  <pre><code>extension SequenceType where Self.Generator.Element : Hashable {
      func countRepetitions() -&gt; [Self.Generator.Element : Int] {
          return self.reduce([Self.Generator.Element : Int]()) { dict, element in
              dict[key: element] = (dict[element] ?? 0) + 1
          }
      }
  }
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Playground execution failed: OS X.playground:26:22: error: type of expression is ambiguous without more context
                  return self.reduce([Self.Generator.Element : Int]()) { dict, element in
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  </code></pre>