[database-devel] Postgresql enum type conversions
Luke Hoersten
luke at hoersten.org
Sat Jun 16 21:02:16 CEST 2012
I'm trying to use postgresql enum types to represent Haskell types
like in the code snippet below but an receiving the following error:
"Incompatible {errSQLType = "x", errHaskellType = "Text", errMessage =
"types incompatible"}"
In other areas of my code (not shown) I'm successfully using Text to
convert to and from Postgersql enum types but it doesn't seem to work
in the case below. Any ideas what I'm doing wrong?
Thanks, Luke
import Database.PostgreSQL.Simple.FromField
(FromField, fromField)import
Database.PostgreSQL.Simple.FromRow (FromRow, field,
fromRow)import Database.PostgreSQL.Simple.SqlQQ
(sql)
data X = X Float
| Y Float
buildX :: Text -> Float -> XbuildX "x" = XbuildX "y" = Y
instance FromField (Float -> X) where
fromField f v = buildX <$> fromField f v
instance FromRow X where
fromRow = field <*> (field :: RowParser Float)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/database-devel/attachments/20120616/54175ba3/attachment.htm>
More information about the database-devel
mailing list