Re: [Haskell-cafe] HDBC convert [SqlValue] without muchos boilerplate

12 Feb
2010
12 Feb
'10
1:36 a.m.
On 11 Feb 2010, at 10:05, Vasyl Pasternak wrote:
But fromSql function could convert everything to String, so you never need to use `show`, just simply write
convrow2 :: [SqlValue] -> String convrow2 (x:xs) = foldl (\i j -> i ++ " | " ++ (fromSql j)) (fromSql x) xs
But, IMO, this is more readable version of your function:
convrow2' :: [SqlValue] -> String convrow2' = unwords . intersperse "|" . map fromSql
On 11 Feb 2010, at 10:06, Miguel Mitrofanov wrote:
What if you just omit the "show" function? fromSql seems to be able to convert almost anything to String.
Ok, thanks, that's a big help. I'm really glad to get rid off all that extra cruft I had there. I'd forgotten about intersperse, too. The new code works fine. Regards, Iain
5578
Age (days ago)
5578
Last active (days ago)
0 comments
1 participants
participants (1)
-
Iain Barnett