title: Scala: Use case for Map.flatten?
body: <p>The <a href="http://scala-lang.org/api/current/index.html#scala.collection.Map@flatten[B]:Map[B]">documentation on Map.flatten</a> states the following:</p>
  
  <blockquote>
    <p>Converts this map of traversable collections into a map formed by the elements of these traversable collections.</p>
  </blockquote>
  
  <p>I get "map of traversable collections." That would be a map of lists, for example. By that definition alone, a <code>Map[Int, List[Int]]</code> would qualify.</p>
  
  <p>But what is "a map formed by the elements of these traversable collections"? It sounds straightforward, but I'm having a hard time getting it to work.</p>
  
  <p>The example code provided in the documentation is ... well ... shall we say, not applicable?</p>
  
  <blockquote>
  <pre><code>val xs = List(
             Set(1, 2, 3),
             Set(1, 2, 3)
           ).flatten
  // xs == List(1, 2, 3, 1, 2, 3)
  
  val ys = Set(
             List(1, 2, 3),
             List(3, 2, 1)
           ).flatten
  // ys == Set(1, 2, 3)
  </code></pre>
  </blockquote>
  
  <p>I've tried a few different things, but they yield the same error. Here are a couple of examples:</p>
  
  <pre><code>scala&gt; val m = Map(List(1) -&gt; List(1,2,3), List(2) -&gt; List(4,5,6), List(3) -&gt; List(7,8,9))
  m: scala.collection.immutable.Map[List[Int],List[Int]] = Map(List(1) -&gt; List(1, 2, 3), List(2) -&gt; List(4, 5, 6), List(3) -&gt; List(7, 8, 9))
  
  scala&gt; m.flatten
  &lt;console&gt;:9: error: No implicit view available from (List[Int], List[Int]) =&gt; scala.collection.GenTraversableOnce[B].
                m.flatten
                  ^
  
  scala&gt; val m = Map(1 -&gt; List(1,2,3), 2 -&gt; List(4,5,6), 4 -&gt; List(7,8,9))
  m: scala.collection.immutable.Map[Int,List[Int]] = Map(1 -&gt; List(1, 2, 3), 2 -&gt; List(4, 5, 6), 4 -&gt; List(7, 8, 9))
  
  scala&gt; m.flatten
  &lt;console&gt;:9: error: No implicit view available from (Int, List[Int]) =&gt; scala.collection.GenTraversableOnce[B].
                m.flatten
                  ^
  </code></pre>
  
  <p>What am I missing? </p>