title: is it possible to parse and consume the results of an aeson parser from a stream in constant space?
body: <p>Note that <strong><a href="https://hackage.haskell.org/package/aeson-0.8.0.2/docs/Data-Aeson-Types.html#v:fromJSON" rel="nofollow">fromJson</a></strong> returns a <strong>Result a</strong>, which can be an <strong>Error String</strong> or <strong>Success a</strong>.  </p>
  
  <p>If I'm using fromJson on a stream  (for example, a <a href="https://hackage.haskell.org/package/http-streams-0.7.2.5/docs/Network-Http-Client.html#g:4" rel="nofollow">response</a> from http-streams using the expression <code>parseFromStream (fromJSON &lt;$&gt; json')</code> ) <a href="https://hackage.haskell.org/package/io-streams-1.2.1.2/docs/System-IO-Streams-Attoparsec.html" rel="nofollow">(link)</a>, does pattern matching on the Result force the whole stream to buffer completely first, in order to the parse to determine success or failure, regardless of whether further consumption of the response is sufficiently lazy (i.e. constant-space parsing+consumption <em>is not</em> possible) ?  Or, can the <strong>both</strong> parsing and result be consumed lazily i.e. constant-space parsing+consumption <em>is</em> possible)?  The docs sau "parseFromStream consumes only as much input as necessary to satisfy the Parser", but it's not clear how "satisfing the Parser" relates to pattern matching on the Result to Produce a Success or Error. </p>
  
  <p>(P.S. Alternatively, it is not possible, is there a different way that allows constant-space parsing w/ consumption?)</p>