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

Iain Barnett iainspeed at gmail.com
Fri Feb 12 01:36:35 EST 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100212/0fb6766d/attachment.html


More information about the Haskell-Cafe mailing list