title: Is there an easy way to get a Stream as output of a RowParser?
body: <p>Given <code>rowParser</code> of type <code>RowParser[Photo]</code>, this is how you would parse a list of rows coming from a table <code>photo</code>, according to the code samples I have seen so far:</p>
  
  <pre><code>def getPhotos(album: Album): List[Photo] = DB.withConnection { implicit c =&gt;
    SQL("select * from photo where album = {album}").on(
      'album -&gt; album.id
    ).as(rowParser *)
  }
  </code></pre>
  
  <p>Where the <code>*</code> operator creates a parser of type <code>ResultSetParser[List[Photo]]</code>. Now, I was wondering if it was equally possible to get a parser that yields a <code>Stream</code> (thinking that being more lazy is always better), but I only came up with this:</p>
  
  <pre><code>def getPhotos(album: Album): Stream[Photo] = DB.withConnection { implicit c =&gt;
    SQL("select * from photo where album = {album}").on(
      'album -&gt; album.id
    )() collect (rowParser(_) match { case Success(photo) =&gt; photo })
  }
  </code></pre>
  
  <p>It works, but it seems overly complicated. I could of course just call <code>toStream</code> on the <code>List</code> I get from the first function, but my goal was to only apply <code>rowParser</code> on rows that are actually read. Is there an easier way to achieve this?</p>
  
  <p>EDIT: I know that <code>limit</code> should be used in the query, if the number of rows of interest is known beforehand. I am also aware that, in many cases, you are going to use the whole result anyway, so being lazy will not improve performance. But there might be a case where you save a few cycles, e.g. if for some reason, you have search criteria that you cannot or do not want to express in SQL. So I thought it was odd that, given the fact that anorm provides a way to obtain a <code>Stream</code> of <code>SqlRow</code>, I didn't find a straightforward way to apply a <code>RowParser</code> on that.</p>