[prev in list] [next in list] [prev in thread] [next in thread]
List: haskell-cafe
Subject: [Haskell-cafe] [Haskell-beginners] Better way to retrieve data
From: Paolo Losi <paolo.losi () gmail ! com>
Date: 2009-09-30 7:49:47
Message-ID: 2af4014d0909300049j3f4ff6f6uf81bdd8833033dda () mail ! gmail ! com
[Download RAW message or body]
Hi Roman,
Template Haskell should be the preferred way to
cope with these "boilerplate" code problems.
Template Haskell: http://www.haskell.org/haskellwiki/Template_Haskell
Note: I'm a beginner myself so please wait for a more informed response.
Paolo
2009/9/28 Roman Naumann <roman_naumann@fastmail.fm>:
> 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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic