I have a table with CHARACTER fields. I tried having a Char type in Haskell and use that, but I kept getting errors that the type was bpchar instead of char.
My current workaround is:
newtype PGChar = PGChar { unPGChar :: Char }
deriving (Eq, Ord, Show, Read)
instance FromField PGChar where
fromField f mdata =
if typeOid f `notElem` [typoid char, typoid bpchar]
then returnError Incompatible f "Must be a single character"
else case unpack <$> mdata of
Nothing -> returnError UnexpectedNull f ""
Just [c] -> return (PGChar c)
Just r -> returnError ConversionFailed f r
I have a table with
CHARACTER
fields. I tried having aChar
type in Haskell and use that, but I kept getting errors that the type wasbpchar
instead ofchar
.My current workaround is: