[Haskell-cafe] Handling custom types in Takusen

Bayley, Alistair Alistair_Bayley at invescoperpetual.co.uk
Fri Jul 27 11:19:32 EDT 2007


> From: Salvatore Insalaco [mailto:kirby81 at gmail.com] 
> 
> 2007/7/27, Bayley, Alistair <Alistair_Bayley at invescoperpetual.co.uk>:
> > > Also, in Sqlite 3.4, they introduced new functions for incremental
> > > reading / writing of Blobs. I could use them in the future.
> >
> > Seems reasonable. I recall Oleg saying something privately 
> a while ago
> > about an API for large objects. He may have some ideas for this.
> 
> A good idea could be to do the marshalling / unmarshalling of Blob as
> CStringLen. It can then be used to construct PackedStrings and
> ByteStrings in O(1), or doing some custom computations with it. A
> CStringLen, even if contains Ptr CChar, can easily be converted to any
> pointer type.
> 
> Another idea could be using custom bind function for blobs, but the
> first solution is surely easier.

It was my intention to do it the other way around: marshall blob to Ptr
(), and then you can cast this to a Ptr CChar. Obviously you'd need to
retain the size information, so a blob basically becomes a (Ptr (), Int)
pair, just like a CStringLen...

At least this way you've got a type which says explicitly "this thing is
a blob", and then if you know better, i.e. it's really a CString, you
can cast it.

Actually, it wouldn't cost much to have both marshalling functions in
the low-level API, even if they both call the same Sqlite blob retrieval
function.

Alistair
*****************************************************************
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
*****************************************************************


More information about the Haskell-Cafe mailing list