On 30 May 2012 04:49, Felipe Almeida Lessa <
felipe...@gmail.com> wrote:
> I'm afraid I don't have anything else to say besides commenting that you
> need to take PersistValue limitations into consideration as well.
What limitations of PersistValue are you referring to? Isn't it a mere
wrapper around a Haskell data type that should store a marshalled cell
value?
> Em 29/05/2012 14:55, "Michael Snoyman" <
mic...@snoyman.com> escreveu:
>> I don't think I really know enough about how PostgreSQL stores this
>> data, or how libpq delivers that data to the application, to give an
>> intelligent answer. A ByteString (or a newtype around one) could be an
>> appropriate solution, as could a sum type. But it really depends on
>> details that I'm not familiar with.
According to inet.h (see
http://doxygen.postgresql.org/structinet.html), the format that
PostgreSQL uses internally for the inet type is this:
typedef struct
{
unsigned char family; /* PGSQL_AF_INET or PGSQL_AF_INET6 */
unsigned char bits; /* number of bits in netmask */
unsigned char ipaddr[16]; /* up to 128 bits of address */
} inet_struct;
typedef struct
{
char vl_len_[4];
inet_struct inet_data;
} inet;
Would it be acceptable to declare a Haskell type just like the
inet_data struct and let applications convert it to their desired
representation as they see fit?
E.g.
data InetFamily = Inet4 | Inet6
data Inet = InetFamily Int [Word16]
I'm not sure where something like that would need to be added. I guess
we'd need to have instance declarations in postgresql-simple first.
(Note: I could be totally wrong.)