Reputation: 324
I am building a haskell server with a postgres database. I am using postgresql-simple to query the db.
I have the following type:
data Reading = Reading
{ id :: UUID
, title :: String
, authors :: [String]
, startDate :: Day
, finishDate :: Maybe Day
}
deriving (Eq, Show, Generic, FromRow)
This results in the following compiler error:
No instance for (Database.PostgreSQL.Simple.FromField.FromField
[String])
arising from a use of ‘Database.PostgreSQL.Simple.FromRow.$dmfromRow’
In the documentation, I do not see an instance defined for [String]
. It seems like one should exist. Is there one I can use or should I be thinking about defining my own?
Edit:
I can define
instance FromRow Reading where
fromRow =
Reading
<$> field
<*> field
<*> (fromPGArray <$> field)
<*> field
<*> field
But this goes into cumbersome territory.
Upvotes: 0
Views: 68