Adding binarySize to Binary

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Sun Feb 4 07:31:21 EST 2007


On Sun, 2007-02-04 at 14:00 +1100, Donald Bruce Stewart wrote:
> ekarttun:
> > Hello
> > 
> > I keep wanting something like:
> > 
> > binarySize :: Binary a => Proxy a -> (Int,Maybe Int)
> > 
> > in the Data.Binary for returning the minimum and maximum (or Nothing
> > for infinite) space requirements for objects of a given type.
> > 
> > Proxy is just defined as "data Proxy t = Proxy", but omitting it
> > is also possible. Would other people consider this an useful
> > addition?
> 
> 
> Yes, I've thought this would be useful too. A la 'sizeOf' in Storable.
> Should it be a member of the Binary class?

What would it mean? How hard would it have to work to be accurate? Is
this just for (mostly-)fixed size records? What about lists? I don't
think we should be forcing the list just to see how big it is.

What is the use-case?


Duncan



More information about the Libraries mailing list