The `StateT` solution you have actually looks pretty close to what I had in mind (at least the parsing part). I think there's only one change you need to make, which is to drain any unused bytes after the user is done parsing the body, like this:

    ...
    a <- zoom (Pb.splitAt (rqLength req)) (handler req <* skipAll)
    lift $ sendResponse a
    ...

`splitAt` only ensures that the parser doesn't overrun the alloted number of bytes. If you add `skipAll` then it ensures that you consume any unused bytes so that subsequent commands begin from after the request body.

On 02/02/2014 07:01 AM, Jeremy Shaw wrote:
On Thu, Jan 30, 2014 at 8:31 PM, Gabriel Gonzalez <[email protected]> wrote:
I think the issue here is that you are exposing the `Producer` to the user
at all.  Like I mentioned in another e-mail, I think the correct API is that
the user provides you with a `Parser ByteString IO ()`.
Right -- that is the 'StateT' based solution I mentioned. This is my
dummy implementation -- which I am still refactoring:

https://github.com/stepcut/hyperdrive/blob/master/experiments/HyperMonad.hs

- jeremy

--
You received this message because you are subscribed to the Google Groups "Haskell 
Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].

Reply via email to