[Haskell-cafe] Re: ANN: A triple of new packages for talking tothe outside world

Don Stewart dons at galois.com
Thu Jan 10 13:45:21 EST 2008


agl:
> On Jan 9, 2008 5:01 PM, David Roundy <droundy at darcs.net> wrote:
> > But I can't imagine an implementation in which this change wouldn't slow
> > down getBytes for the normal case.  Perhaps the slowdown would be small,
> > but it seems unwise to enforce that slowness at the API level, when we've
> > already got a perfectly good API for fast binary IO.  Maybe there's some
> > type hackery you could do to avoid a speed penalty, but that's a lot to add
> > for a somewhat dubious benefit.
> 
> I believe that it would be an additional if statement in the fast path at least.
> 
> How about a BitGet monad which get be run in the Get monad?
> 
> > test :: Get ()
> > test = do
> >  runBitGet 2 (do
> >    getBitField 2)
> 
> So the first argument to runBitGet is the number of bytes to parse for
> bit fields and then functions in BitGet can extract bit-length ints
> etc.
> 
> Anyone like that idea?

That's pretty much what we envisaged as the approach to take.
Monad transformers adding some bit-buffer state over Get/Put.

-- Don


More information about the Haskell-Cafe mailing list