如何访问查询 [VarcharIntDate] 中的数据?
data VarcharIntDate = VarcharIntDate {
vc :: Maybe String,
i :: Maybe Int,
d :: Maybe Date
} deriving (Show)
instance FromRow VarcharIntDate where
fromRow = VarcharIntDate <$> field <*> field <*> field
我知道如何打印它,但我不能用它做很多其他事情,因为我不明白如何处理'IO [VarcharIntDate]'
print =<< ( query_ conn "select vc,i,d from varintdate" :: IO [VarcharIntDate] )
但我想做的是从返回的 [VarcharIntDate] 的第 n 行访问“d”或从所有行访问“i”,这样我就可以开始从查询中提取数据并开始使用它。