[Haskell-beginners] Better way to retrieve data strucures from sql-db?

Roman Naumann roman_naumann at fastmail.fm
Mon Sep 28 12:55:00 EDT 2009


The following function converts the data read from an sql database to a 
player data structure.

toPlayer    :: [SqlValue] -> Player
toPlayer sx = Player {
                  plID       = fromSql (sx!!0),
                  plAccount  = fromSql (sx!!1),
                  plForename = fromSql (sx!!2),
                  plSurename = fromSql (sx!!3),
                  plPos_x    = fromSql (sx!!4),
                  plPos_y    = fromSql (sx!!5)
               }


It appears to me, that I have to write this boilerplate code every time 
I introduce a new data structure that has to be read from the sql 
database. Can you think of a way to automate this?

Thanks for your replies,
Roman Naumann

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
Url : http://www.haskell.org/pipermail/beginners/attachments/20090928/23ead438/signature.bin


More information about the Beginners mailing list