On 18 April 2011 12:48, Simon Marlow <marlo...@gmail.com> wrote: > I'm not sure about the motivation for the factoring here, You've added an > extra member to BufferCodec: > > + recover :: Buffer from -> Buffer to -> IO (Buffer from, Buffer to), > > but this always seems to be instantiated by either recoverDecode or > recoverEncode. Furthermore the Handle implementation always calls > streamEncode, which uses encode and recover in a particular way.
Right, but GHC.Foreign uses them in another way which actually makes use of the information about why encode/decode stopped. The streamEncode function is just a wrapper that tries to gets back the original interface that encode/decode had before my changes, purely for use in the Handle code. It might be possible to change Handle to use the new encode/decode directly (and I suspect it might even clean up the Handle code a bit). I was too afraid of the possibility of introducing subtle new bugs in Handle to go that route right now. Bottom line: I think we do need the separate "recover" member because the two call sites of "encode" wrap it up with "recover" in a different way. > yet we're given the size of the input in bytes, so we can do much better. Good point, fixed that. Cheers, Max _______________________________________________ Cvs-ghc mailing list Cvs-ghc@haskell.org http://www.haskell.org/mailman/listinfo/cvs-ghc