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 -> X
buildX "x"      = X
buildX "y"      = Y


instance FromField (Float -> X) where
    fromField f v = buildX <$> fromField f v


instance FromRow X where
    fromRow = field <*> (field :: RowParser Float)