[Haskell-cafe] Handling custom types in Takusen

Bayley, Alistair Alistair_Bayley at invescoperpetual.co.uk
Fri Jul 27 10:10:01 EDT 2007


> I noticed that in Takusen there're just two instances to implement to
> make any Haskell type db-serializable: DBBind / SqliteBind for
> serialization and DBType for deserialization.
> 
> I wanted to implement blob serialization for PackedStrings, but I
> noticed that both DBBind and DBType classes are not public.
> Defining custom serialization (not just Show  / Read string
> serialization) is very useful in applicative code, and not just in
> Takusen backend code.
> 
> There's any way to do it without modifying Takusen Sqlite backend?
> 
> Salvatore Insalaco

Sorry, not at present. It shouldn't be hard to modify the code though,
and PackedString support is something we should really be thinking about
anyway (as well as Blobs, which I think should have a different type).

Although DBType is a class in InternalEnumerator (so you'd think it
might be easy to extend with new types), in practice we do not expose
the internal Query and ColumnBuffer objects that you also need to create
new instances of the class, so you're stuck with what we provide. This
is intentional; you usually need to access the low-level buffers and
other resources to write an instance on DBType, and we don't want to
expose these details to users. By hiding this stuff, we can ensure that
resources are properly cleaned up when queries and commands complete.

So, please take this as an invitation to modity the Sqlite
implementation to handle PackedStrings (and Blobs, if you want to).

BTW, do you really need to marshall PackedStrings to blobs? The Sqlite
library uses CStrings, and I assume that CString to PackedString
marshaling is fairly efficient, so that would seem to be a better
choice. (I have no experience of PackedStrings, so there might be good
reasons to prefer blobs, and I'd like to know what they are.)

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