Hello,
I am sending this via webmail, so hopefully it comes through ok :p
The Read (Record r) instance seems to be broken. It works fine if you are
reading *just* a (Record r), but you have a data type that includes a
(Record r), such as a list, [(Record r)], then it fails.
I believe this is because readsReadRecRow is not returning the unused
portion of the string. So, in the list example, the ] that closes the list
gets thrown away, resulting in the read of the list failing.
This version works better for me, in my 30 seconds of testing:
> readsReadRecRow :: ReadRecRow r => ReadS r
> readsReadRecRow s = [(r,leftOver) | (l,leftOver) <- reads s, (r,[]) <-
readRecRow l]
Here is the test I use -- it just does a 'show' on all the rows in a
table, and then tries to 'read' them back.
> test =
> mysqlConnect (MySQLOptions "host" "db" "user" "passwd" ) $ \db ->
> query db (table testTable) >>= \(r :: t) -> print (read (show r) :: t)
Jeremy Shaw.
ps. I darcs send'd the patch directly to the list, but it had
my non-subscribed email, so it is in the moderation queue. You can
ignore that version as the version attached to this message is the same
thing.
---------------------------- Original Message ----------------------------
Subject: darcs patch: fix Read (Record r)
From: je...@n-...
Date: Fri, March 10, 2006 9:48 pm
To: jer...@li...
--------------------------------------------------------------------------
Fri Mar 10 21:37:29 PST 2006 je...@n-...
* fix Read (Record r)
Previously, readsReadRecRow did not return the unconsumed portion of the
string, it just threw it away. This meant that you could read a single
(Record r), but you could not read a (Record r) that was inside another
data type, eg [(Record r)].
This patch, hopefully, fixes the problem. I have not tested it
extensively yet.
|