From: Bjorn B. <bri...@cs...> - 2006-03-11 12:29:42
|
jer...@li... wrote: > Hello, >=20 > I am sending this via webmail, so hopefully it comes through ok :p >=20 > The Read (Record r) instance seems to be broken. It works fine if you a= re > 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. >=20 > I believe this is because readsReadRecRow is not returning the unused > portion of the string. So, in the list example, the ] that closes the l= ist > gets thrown away, resulting in the read of the list failing. >=20 > This version works better for me, in my 30 seconds of testing: >=20 >=20 >>readsReadRecRow :: ReadRecRow r =3D> ReadS r >>readsReadRecRow s =3D [(r,leftOver) | (l,leftOver) <- reads s, (r,[]) <= - >=20 > readRecRow l] >=20 > 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. >=20 >=20 >>test =3D >> mysqlConnect (MySQLOptions "host" "db" "user" "passwd" ) $ \db -> >> query db (table testTable) >>=3D \(r :: t) -> print (read (show r) :: = t) >=20 >=20 > Jeremy Shaw. Thanks! The old version was weird, I guess noone ever tried to use it=20 for anything serious. I've pushed the patch to the main repo. > 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. This one apparantely wasn't accepted either, but I've now added both=20 your addresses to the accept list. > ... /Bj=F6rn |