[database-devel] ByteString and Text - any conventions?

Janne Hellsten jjhellst at gmail.com
Sun Aug 12 20:18:14 CEST 2012


While working on https://github.com/nurpax/sqlite-simple there have
been occasions when I've tried to decide whether to use ByteStrings or
Text strings.

I note that postgresql-simple and mysql-simple use ByteStrings
exclusively in the API.

Has a convention formed in the Haskell community on which strings
should be used in APIs that pass strings around?

In my case, blobs will anyway be passed around as ByteStrings.  But
SQLite's C strings are UTF8 and some might prefer to Text over
ByteStrings.  Or support both in the API?

This matters in the low-level bindings too, where result accessors
need to return either ByteStrings or Text objects for TEXT fields.
Currently direct-sqlite uses the String type but Irene is thinking of
changing the type to a more efficient representation
(https://github.com/IreneKnapp/direct-sqlite/issues/3).

Sqlite-simple links against both bytestring and text already, so from
a purely package dependency point of view the choice doesn't really
matter.  But sqlite-direct will need to choose one or the other for
its string type in the SQLText s constructor.

Any thoughts?

Cheers,

Janne



More information about the database-devel mailing list