title: Scala for comprehension for Slick Query
body: <p>I'm new to Scala and I'm building a Play app to learn Scala and Slick.  The app has todo lists and each list has items.  Each user has multiple lists.  I've written a controller to get the list as JSON, and the JSON includes all the items in the list.</p>
  
  <pre><code>  def viewList(id: Long) = AuthenticatedAction.async { implicit request =&gt;
      val userId = request.user.toLong;
      db.run(todoLists.filter(listById(id, userId)).result.headOption).flatMap { list =&gt;
        list match {
          case Some(_) =&gt; {
            val json = toJson(list).as[JsObject]
            // Fetch the items in this list and add them to the JSON response
            db.run(todoItems.filter(_.listId === id).sortBy(_.text).result).map { items =&gt; 
              Ok(json + ("items" -&gt; toJson(items)))
            }
          }
          case None =&gt; Future.successful(NotFound)
        }
      }
    }
  </code></pre>
  
  <p>Is it possible to write this function using a for comprehension?  I have a nested flatMap+map call, so it seems like it should be possible.</p>