| 1 | module Msg where |
| 2 | |
| 3 | import Database.HDBC |
| 4 | |
| 5 | type ID = String |
| 6 | |
| 7 | data Msg = Msg { myid :: ID |
| 8 | , path :: FilePath |
| 9 | , paid :: ID |
| 10 | , date :: String |
| 11 | } deriving (Eq, Show) |
| 12 | |
| 13 | toMsg :: [SqlValue] -> Msg |
| 14 | toMsg [a,b,c,d] = Msg { myid = fromSQL a |
| 15 | , path = fromSQL b |
| 16 | , paid = fromSQL c |
| 17 | , date = fromSQL d |
| 18 | } |
| 19 | where |
| 20 | fromSQL SqlNull = "" |
| 21 | fromSQL x = fromSql x |
| 22 | |
| 23 | toMsg _ = error "toMsg" |
| 24 | |
| 25 | fromMsg :: Msg -> [SqlValue] |
| 26 | fromMsg msg = [ toSql (myid msg) |
| 27 | , toSql (path msg) |
| 28 | , toSql (paid msg) |
| 29 | , toSql (date msg) |
| 30 | ] |