
On 12-03-10 05:19 PM, Twan van Laarhoven wrote:
On 2012-03-10 11:16, Paolo Capriotti wrote:
Another issue is how to deal with unconsumed input. For that, there is a ChunkPipe type (in pipes-extra) with a specialized monad instance that threads unconsumed input along. You can see an example of ChunkPipe in action in this prototype http server by Jeremy Shaw: http://src.seereason.com/pipes-http-2/pipes-http-2/. Note that this is based on a old version of pipes-core, however.
A nice way to deal with unconsumed input (from a user's perspective) would be a function
-- | Pass some unconsumed input back upstream. -- The next @await@ will return this input without blocking. unawait :: Monad m => a -> Pipe a b m ()
The function may be called unawait, but there's nothing stopping you from inserting something into the stream that wasn't in the input to start with. I find that this approach breaks too many invariants.