
28 Sep
2009
28 Sep
'09
12:55 p.m.
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